Keep rotation as actor stops (random movement)

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

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @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

  • fiorentinfiorentin Member Posts: 58
    edited September 2013
    Hi @gyroscope,

    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.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    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

  • fiorentinfiorentin Member Posts: 58
    Hmm nope still no luck. Im gonna keep on trying but if you or anyone else comes up with an idea I would be most grateful!

    F
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited September 2013

    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

  • fiorentinfiorentin Member Posts: 58
    It doesn't feel like a real solution but i almost got it to work by putting even more timers in and setting the Change Velocity down to 0,01. Zero will still kill the angle but at 0,01 it will remain. So almost there. I will move on to other parts now but will eventually come back to this problem. If I come up with something ill post it here.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited September 2013

    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

  • fiorentinfiorentin Member Posts: 58
    Thanks for the codes, i will look into it and report back!
Sign In or Register to comment.