One for the math heads: orbit around a point

alkexalkex Member Posts: 38
edited November -1 in Working with GS (Mac)
Hello all!

I would like to make my actor orbit around another object, (like a yoyo swinging around your finger.)
I was hoping to have control over the speed and direction too.

I'm really useless at math but assuming there is a formula I can use that would determine it's coordinates from pivot, angle and distance.

Any guidance would be greatly appreciated!
Thanks

Alex

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    ok here you go:
    http://dl.dropbox.com/u/5068448/orbit.zip

    download that and unzip it.

    wherever you drop the orbit actor, that becomes it's center point. By adjusting the local attributes on the actor orbitDistance and orbitSpeed, you can adjust the diameter of the circle, and the speed it travels around
  • alkexalkex Member Posts: 38
    HI Jonmulcahy,

    I just got home and what a pleasant surprise.
    This is fantastic - thanks so much !
  • okimokiokimoki Member Posts: 159
    soooo.. im hijacking this thread since its on a same subject and alkex already got what he needed..

    I wanna make it so that when you press left arrow the actor revolves left, right to right.. i already set it up, but the problem is that sin and cos are using Time, and that makes the actor jump to another location when you release left (actor stops) then when you press right jumps to another location along the circular path and starts revolving right from there..

    any thoughts?
  • alkexalkex Member Posts: 38
    I have one more question regarding the demo you sent me, Jonmulcahy:

    How would I proceed to make multiple actors orbit around the same point, at the same speed, same direction but offset from each other.

    I tried spawning them at 1 second intervals but they "stick" together.
    I also tried a few things in the math formula but that didn't seem to work.
    I'm guessing game.time needs to be changed to a unique value for each actor?

    Thanks in advance
  • alkexalkex Member Posts: 38
    Figured it out!

    Subtracting an amount from game.time offsets the actor.
    No I'm never going to get any sleep :)

    okimoki, maybe try replacing game.time with a controlled value..
    sorry, I'm still at the very beginning of the gamesalad adventure
    Cheers
    Alkex
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    yea, if you just replace game.Time with your own attribute you can control when it moves. you just have to use a timer to adjust that value
  • JlmCJlmC Member Posts: 129
    okimoki said:
    soooo.. im hijacking this thread since its on a same subject and alkex already got what he needed..

    I wanna make it so that when you press left arrow the actor revolves left, right to right.. i already set it up, but the problem is that sin and cos are using Time, and that makes the actor jump to another location when you release left (actor stops) then when you press right jumps to another location along the circular path and starts revolving right from there..

    any thoughts?

    This...
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    jonmulcahy said:
    yea, if you just replace game.Time with your own attribute you can control when it moves. you just have to use a timer to adjust that value

    This... :)

    in more detail:

    create an attribute called customTime. replace game.Time with customTime.

    then create two rules

    when leftKey pressed

    Timer
    every .5 seconds
    change customTime = customTime+5

    when rightKey pressed
    Timer
    every .5 seconds
    change customTime = customTime-5

    you'll have to play around with the values to adjust how smooth / fast you want it.
Sign In or Register to comment.