Detect linear velocity in a circular movement.
Hey guys.
I've been wrapping my mind a bit on this one and I just cant get a hang of it. I was wondering if someone can help me.
I have an actor that moves in a circle. I program that actor to move in a circle using the following formulas:
constrain attribute: self.position.X to: 40*cos(self.Time*600%360)+240
constrain attribute: self.position.Y to: 40*sin(self.Time*600%360)+160
This works very well but I'm trying to make the actor face forward on the direction that he is going. The way I normally do this is have a rule that says:
When linear velocity X > 0 display image of actor facing right. Otherwise (when linear velocity X < 0) display image of actor facing left.
But on the circular movement actors, the linear velocity is always 0, because im not using any move behaviors.
Any idea how to detect if the actor is moving right or left so I can change the image of the actor facing right or left.
Thank you very much.
Steve
I've been wrapping my mind a bit on this one and I just cant get a hang of it. I was wondering if someone can help me.
I have an actor that moves in a circle. I program that actor to move in a circle using the following formulas:
constrain attribute: self.position.X to: 40*cos(self.Time*600%360)+240
constrain attribute: self.position.Y to: 40*sin(self.Time*600%360)+160
This works very well but I'm trying to make the actor face forward on the direction that he is going. The way I normally do this is have a rule that says:
When linear velocity X > 0 display image of actor facing right. Otherwise (when linear velocity X < 0) display image of actor facing left.
But on the circular movement actors, the linear velocity is always 0, because im not using any move behaviors.
Any idea how to detect if the actor is moving right or left so I can change the image of the actor facing right or left.
Thank you very much.
Steve
Comments
Constrain Attribute: self.Rotation to: vectorToAngle( self.Position.X -240, self.Position.Y -160)
(the 240 and 160 are just the center of the screen, they can whatever point you want.)
That will make the actor face the outside of the circle as it rotates. If you simply want to have the actor ONLY face left or right, you can base that on it's X position relative to the center point. i.e. > 240 face right, < 240 face left.
Also, in your above formulas, %360 is not necessary.
Should work.