How do I prevent flipping back objects angle in 8direction

0 favourites
  • 6 posts
From the Asset Store
Flip Timer for Games
$17.15 USD
65% off
Goodbye to sprite fonts, when you have something new on the anvil for your upcoming Games !
  • Hello,

    in my game I use 8direction with keyboard controls for player movement. After release of the diagonals (left/up, left/down and so on), the player object always flips back to one of the 4direction angles (0°, 90°, 180°, 270°).

    How can i prevent this flipping?

    Thanks

  • Would adding an on any key released sprite set angle : sprite.8Direction.MovingAngle work?

  • Sadly this doesn`t work. Im using an adapted 8dir from the tutorial "Animation Management in 8-Direction Games" by stemkoski.

    I attached a Capx.

    Any idea how to implement my needs?

  • 1. add instance variable "movingAngle" on your Player

    2. (Add event)

    ---keyboard -> On any key released

    ---player -> is moving

    (Add action)

    ---Player -> Set value -> movingAngle= Player.angle

    3. (Add event)

    ---Player -> is moving -> invert

    (Add action)

    ---Player -> Set angle -> Player.movingAngle degrees

  • Thank you very much puntodamar.

    After diagonal move player object and so the player animation are flipping to the correct angle. Is there a way to let it look more clean?

    My idea was to make this flipping so fast that it would not be visual for the eye. I added an every tick event. Didn´t work.

    I reduced the angles in the player movement events. Also no great idea.

    Im stuck and need help.

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • inside "Player Movement" group, delete all events with "Is between angles" condition.

    then, add the following events inside "Player Controls" group

    1. Keyboard -> Key A & W is down

    --- Player -> set angle to 255, set DirectionName to "NW", set movingAngle to Player.Angle

    2. Keyboard -> A & S is down

    --- Player -> set angle to 135, set DirectionName to "SW", set movingAngle to Player.Angle

    3. Keyboard -> Key D & S is down

    --- Player -> set angle to 45, set DirectionName to "SE", set movingAngle to Player.Angle

    4. Keyboard -> Key D & W is down

    --- Player -> set angle to 255, set DirectionName to "NE", set movingAngle to Player.Angle

    5. delete event 15

    it's not completely fixed, because you have to release two button together to make it happen.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)