rotate actor to direction its going?
UtopianGames
Member Posts: 5,692
Hi Guys,
This question has been ask several times so im hoping someone would be so kind and do a simple demo.
I'm trying to have a round actor (with arrow pointing right sprite for eg) and wondering how to rotate this actor to point the arrow in the same direction.
If the actor moves up the arrow will point/rotate up (would like it in all possible directions though).
Thanks for looking and i hope you can help me and several other gs users.
Darren.
This question has been ask several times so im hoping someone would be so kind and do a simple demo.
I'm trying to have a round actor (with arrow pointing right sprite for eg) and wondering how to rotate this actor to point the arrow in the same direction.
If the actor moves up the arrow will point/rotate up (would like it in all possible directions though).
Thanks for looking and i hope you can help me and several other gs users.
Darren.
Comments
Wherever your 'move' command is also put in rotate to angle (relative to scene) adjust the speed to make it as fast as you want, & the direction the same as the move direction.
So if your move direction is 90, make the rotate to angle 90.
If this is not what you mean give me a little more info on what you want.
Imagine a bullet or rocket that moves around bouncing off other actors but the bullet always points to the way its moving.
Hope this explains more clearly.
Darren.
constrain
self.rotation to vectorToAngle(self.MotionLinearVelocity.X, self.Motion.LinearVelocity.Y)
`
Note: You may have to add a constant value to the above depending on what direction your actor's image faces. I think if you assign an image to the actor that faces/points upward, then you add like "90" to the value above. For example:
`
constrain
self.rotation to vectorToAngle(self.MotionLinearVelocity.X, self.Motion.LinearVelocity.Y) + 90
`
Guess you know im happy with that and it works a treat!
Thanks so much Red!
Darren.
(although I think this is a reference to the first time someone, you?, called me "redump"...so if that is the case...too funny!) :-D