Need more constraining help!!!

mrglocklingmrglockling Member Posts: 258
edited January 2012 in Working with GS (Mac)
Thanks to Some Sou Chefs for helping me keep one actor in the same spot as another. But i ran into a problem! my actor follows my other actor but my main actor rotates and the following actor doesnt. Hope that makes sense? is there any way i can keep my actor in one spot at ALL times even when rotated?

-Max

Comments

  • hotMagichotMagic Member, PRO Posts: 266
    If you want it to stay in the same spot as the main actor while rotating, you'll need to use sin and cos to find the location to constrain to.
  • mrglocklingmrglockling Member Posts: 258
    How would I use sin and cos?
  • hotMagichotMagic Member, PRO Posts: 266
    You constrain the second guy's position X to this formula:
    littleGuyx=distance offset * cos(mainDude Rotation)
    (it basically gives the distance from the main dude horiz)
    Constrain littleGuy Y to:
    Y=distanceoffset * sin(mainDude rotation)
    (to get the vertical)

    Check this out, we are basically getting the adjacent angle on the X part and the opposite on the Y, since we know the hypotenuse, which is the distance offset that you specify.

    http://www.mathsisfun.com/sine-cosine-tangent.html
  • mrglocklingmrglockling Member Posts: 258
    Thanks everyone I successfully fixed my problem turned out my computer was lagging out and the preview got quirky.
    @hotMagic Thank you I will definitely use this later on ;)
  • mrglocklingmrglockling Member Posts: 258
    Ok so after I gave my ship turret a 30 px Y off set I started doing the same thing again :( so I tried this but it doesn't work? This is my formula "game.small ship x=0*cos(game.Destroyer Rotation)" this is for X

    For Y I got " game.smallship y=30*sin(game.Destroyer Rotation)"

    Any Idea? What should I change?

    -Max
  • flapairflapair Member Posts: 67
    edited January 2012
    --- Delete please! I didn't saw the other comments ---
  • mrglocklingmrglockling Member Posts: 258
    ?
  • hotMagichotMagic Member, PRO Posts: 266
    Sorry I forgot to mention it needs to be relevant to your location.
    So it would be smallShipX + (the formula you have above)
    Because for example, in the example you give, the X would be at 0, not relevant to Big ship but to the screen.

    Same for Y.
  • mrglocklingmrglockling Member Posts: 258
    Ok so all together it would be smallShipX+(game.small ship x=0*cos(game.Destroyer Rotation)) for X
    and smallShipY+( game.smallship y=30*sin(game.Destroyer Rotation)) For Y?
  • mrglocklingmrglockling Member Posts: 258
    Never mind this thread after working so hard I tried this in the web viewer and it doesn't load the gameplay :( maybe to many constrain attributed or something oh we'll I'll figure a new game out
Sign In or Register to comment.