Help with moving revolving object
originalrealtonytones
Member, PRO Posts: 12
Hi all,
I have a problem that I'm not sure how to fix. I have an object, that i've managed to figure out how to make it revolve around a centre point thanks to the forums. For this i am using constrain attribute, not sure if i should though, as while it is doing its revolution i would like it to move from the right to the left of the screen if this makes any sense.
Constrain Attribute Position X - 50cos( game.Time *-150)+200
Constrain Attribute Position Y - 50sin( game.Time *-150)+40
So I want it to revolve anticlockwise, which is working perfectly for me. Though i can't seem to make it move while doing that. If anybody could provide some info on how to do this, or what i need to change to make things work that would be great.
T
Comments
At the moment, how you've have your constrains set up . . .
Constrain X to 50 * cos( game.time *-150)+200
Constrain Y to 50 * sin( game.time *-150)+40
. . . means the actor will be moving in a clockwise direction rather than a counterclockwise direction. Angles, in maths, start at 0° (the 3 o'clock position) and move counterclockwise towards 90° (the 12 o'clock position). But your angles are decreasing because you have a minus sign in front of the game.time multiplier.
tl;dr are you sure it's CCW at the moment ?
The two values at the end of your constrain behaviours define the centre of the orbit, if you want to move the whole system across the screen (along the X axis) then you would change the '+200' value to change the system's x position.
For example . . .
Interpolate AAA from 1000 to 0
Constrain X to 50 * cos( game.time *-150)+AAA
Constrain Y to 50 * sin( game.time *-150)+40
. . . or . . .
Constrain X to 50 * cos( game.time *-150)+(1024-(game.time *100))
Constrain Y to 50 * sin( game.time *-150)+40
. . . or . . .
Constrain X to 50 * cos( game.time *-150)+mouse X
Constrain Y to 50 * sin( game.time *-150)+mouse Y
. . . etc etc
P.S
Testing has shown that self.time is more efficient than game.time - it's not an enormous difference, but in all my tests - with a project set up to run at 50fps - using self.time had a 1fps advantage over game.time.
Example file attached:
Got carried away:
Lol. Whoops. I did a typo!
Meanwhile you're brilliant. I'll try it all out later and let you know how I go. Thanks heaps Mr!!!