How to rotate actor to directional of movement?

I'm trying get my actors to rotate up when i move up, down when i move down, etc. I have been able to get the actors to rotate in a direction, but after they rotate the controls change and up is no longer up and down is no longer down. So how do i get my actors to rotate up when i have them moving, rotate right when they are moving right, etc. I just want the actors to rotate in increments of 90 degrees an not stop at degrees not divisible by 90.

Comments

  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    I believe TSB has a video about this on his channel somewhere. I know he made a game with the concept once called "Warped". So yes, it is certainly possible.
    If you can't find the video, tag me (@SnapFireStudios), and I'll help you out.
    - Thomas
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Try this:

    Constrain Attribute: [self.Rotation] To: [vectorToAngle(self.Motion.Linear Velocity.X,self.Motion.Linear Velocity.Y)]
  • TyDietrichTyDietrich Member Posts: 45
    I did this an it rotates, but now whenever I let go of the key that i am moving with (up, down, left, an right), the actor rotates uncontrollably for a second then stops at the location that it starts at (facing right). So how do I keep the actor rotated in the direction its moving when it stops, an then be able to change rotation to the next directional key. Ex. Rotate up when i move up, let go of key, actor still facing up. Rotate left when i move left, let go of key, actor still faces left, etc.?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    How about this:

    When up key is pressed
    -- Change Attribute: [self.Rotation] To: [90]
    -- Change Velocity, Direction: [90]

    When left key is pressed
    -- Change Attribute: [self.Rotation] To: [180]
    -- Change Velocity, Direction: [180]

    When down key is pressed
    -- Change Attribute: [self.Rotation] To: [270]
    -- Change Velocity, Direction: [180]

    When right key is pressed
    -- Change Attribute: [self.Rotation] To: [0]
    -- Change Velocity, Direction: [0]
  • michi1157michi1157 Member Posts: 2
    Will this also work for an ipad with (touch is pressed) in place of (up key, left key, down key and right key?) or do i have to add something else to it? I followed a video on youtube made from tshirtbooth, but it doesn't stop at the specific angle, it keeps rotating non stop. I have a gun that I want to rotate upwards and downwards to aim when touched, but it doesn't stop it keeps rotating completly to 180.
Sign In or Register to comment.