attaching an actor to follow the main actor with cos and sin

openmarketintlopenmarketintl Member Posts: 4
edited December 2011 in Working with GS (Mac)
Dose anyone knows how to make one actor to be attached /connected to my main actor border (not to its center) and to rotate together with the main actor as well.
so lets say that my main actor is a plant erath and i want that the moon actor will follow earth and also will rotate the same as it around it. i know its something with cos and sin that keeps the secondary actor to the point i what relative to the main actor and in the distance from it but whats the rest??
Thanks

Comments

  • JPickardJPickard Member Posts: 477
    Look at the Ferris Wheel demo in the New section of GameSalad app. I think that might get you started.
  • mu-kowAPPSmu-kowAPPS Member Posts: 233
    Main actor x + cos(desiredangle%360)*(desireddistancefrommainactorx)

    Main actor y + sin(same as above

    If you want it to rotate around, you could have a timer that changes desired angle to desired angle+1 every how ever many seconds you want

    Try it out
  • openmarketintlopenmarketintl Member Posts: 4
    Thank you very match, that worked out fin with few small changes
  • openmarketintlopenmarketintl Member Posts: 4
    and how i can set a rotation speed to it?
    so i want that the secondary actor will rotate as the main actor but with a slower speed so it will finish it rotation later
  • mu-kowAPPSmu-kowAPPS Member Posts: 233
    edited December 2011
    U want the second actor to "orbit" the first actor at a slower speed? Or u want it to rotate itself?
  • openmarketintlopenmarketintl Member Posts: 4
    yes, the second actor need to follow the main actor rotation but to compete its rotation in a slower speed
  • mu-kowAPPSmu-kowAPPS Member Posts: 233
    I think I know what u want.

    Constrain the main actors rotation to a game attribute

    Mainactorrotation


    In the second actor, have a self attribute

    Desiredangle

    Use the desiredrotation In the sin/cos rules.

    Add another rule inside the second actor that

    When desiredangle does not equal mainactorrotation
    Timer every whatever seconds
    Change attribute desired angle to desired angle+1

    Something along those lines should work

    you might have to use floor on some stuff to take into account the decimals of the angle.

    Is that what you are asking for?
Sign In or Register to comment.