Keep rotation as actor stops (random movement)
fiorentin
Member Posts: 58
Hi,
Im trying to add some random movement to an actor. The movement is fine - im using Timers with random Change Velocity attributes. The rotation is constrained with VectorToAngle so the actor is always facing the direction of the movement.
The problem im having is when the actor stops (which its supposed to do from time to time). The Change Velocity attribute forces the direction back to zero (or a fixed angle) so every time it stops i loose the actors rotation.
Is there a way to kill the movement but keep the angle of the actor? Maybe I shouldn't use Change Velocity at all but some other attribute?
Kindly
F
Im trying to add some random movement to an actor. The movement is fine - im using Timers with random Change Velocity attributes. The rotation is constrained with VectorToAngle so the actor is always facing the direction of the movement.
The problem im having is when the actor stops (which its supposed to do from time to time). The Change Velocity attribute forces the direction back to zero (or a fixed angle) so every time it stops i loose the actors rotation.
Is there a way to kill the movement but keep the angle of the actor? Maybe I shouldn't use Change Velocity at all but some other attribute?
Kindly
F
Comments
@fiorentin
Hi F, without testing - so off the top of my head - what about using a Constrain behaviour on the actor's angle attribute, and when you change velocity to zero, change the Direction to the angle attribute?
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
That was my idea and i tried it again but cant get it to work. Maybe i overcomplicate things. Could it be the constrained VectorToAngle that overrides the angle attribute? Since speed is zero motion is zero and so the rotation will jump back to zero.
Oh, I see now, wasn't thinking clearly enough, putting the angle into the Change Velocity behaviour won't affect the actual angle (rotation position) of the actor, of course.
So perhaps try stopping the actor with Change Attribute with self.Motion.Linear Velocity.X and Y... hopefully it should keep its angle that way. If not, I'll think again... :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
F
What a shame, OK, one last idea: using Change Attribute with self.Motion.Linear Velocity.X and Y to stop the actor, then Change attribute self.Rotation to vectorToAngle...(or maybe the other way around).
...or even Change attribute self.Rotation to vectorToAngle will work just before stopping the actor with Change Velocity to 0, as you first had...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Good work then @fioretin.
Here's a few more thoughts though - still using Change Velocity set to 0 to stop your actor:
-------Angle attribute called ActorAngle
Constrain Attribute self.ActorAngle to vectorToAngle(x,y)
Change Velocity to 0
Change Attribute self.Rotation to self.ActorAngle
--or maybe, to catch the last angle before the change velocity, so the constrain isn't needed:
Change Attribute self.ActorAngle to vectorToAngle(x,y)
Change Velocity to 0
Change Attribute self.Rotation to self.ActorAngle
---------
or, surely this might have a chance:
Constrain Attribute self.ActorAngle to vectorToAngle(x,y)
Change Velocity to 0 Direction: ActorAngle
----or
Change Attribute self.ActorAngle to self.Rotation
Change Velocity to 0 Direction: ActorAngle
--- although some of those I might already have suggested...I'd set up a GS test if I had time, rather than thinking ideas...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps