Changing direction on moving actor in ellipse pattern

BrynjeBamsenBrynjeBamsen Member Posts: 188
edited November -1 in Working with GS (Mac)
let me see if i can explain my self.

I have an actor moving in an almost circular pattern.

Contrain attribute
self.position.x to 450*cos(self.Time*60%360)+512
Contrain attribute
self.position.y to 320*sin(self.Time*60%360)+384

This gives a nice circle movement.

then to change direction i use an integer with %2 toggle when touch i pressed

Contrain attribute
self.position.x to 450*cos(self.Time*-60%360)+512
Contrain attribute
self.position.y to 320*sin(self.Time*-60%360)+384

NOW... heres what gives me a headache.
The actors position jumps around when i change direction, instead of just moving in the other direction

Except when Y mouse position is 512 or = actor self initial position

EDIT: VIDEO

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Hi,

    Unfortunately its not a matter of multiplying by a negative.

    The key to this is the way you increment the actors movement forward (or backward). The equation you have come up with uses self.time to step the actor around. But time only goes forward. Instead of self.time -- set up a counter that you can add and subtract to/from.

    Make a new attribute. Call it "counter" and set it to type real.

    In the equations, replace 'self.time' with the "counter" attribute.

    Set your toggle to either add or subtract .1 to/from the counter. (If toggle is 0 then counter = counter +.1) (If toggle is 1 then counter = counter -.1)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    RThurman said:
    Hi,

    Unfortunately its not a matter of multiplying by a negative.

    The key to this is the way you increment the actors movement forward (or backward). The equation you have come up with uses self.time to step the actor around. But time only goes forward. Instead of self.time -- set up a counter that you can add and subtract to/from.

    Make a new attribute. Call it "counter" and set it to type real.

    In the equations, replace 'self.time' with the "counter" attribute.

    Set your toggle to either add or subtract .1 to/from the counter. (If toggle is 0 then counter = counter +.1) (If toggle is 1 then counter = counter -.1)

    words of wisdom ;)
Sign In or Register to comment.