How do I test for a direction change?

  • I'd like to check if the player has changed direction, is it possible without messy variables to set and test directions?

  • One variable and one event would usually do:

    Give the player a variable oldAngle

    player compare variable Oldangle is not player.angle

    Add your events

    set oldangle to player.angle

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's actually a really good idea, I used PlayerObject.Platform.VectorX > 0 and Press Left Arrow or PlayerObject.Platform.VectorX < 0 and Press Right Arrow, I think your method might be better for controls that aren't just left or right so I'll try implementing it that way, shame C2 doesn't have a built-in test for direction change though!

  • Well, because most of the time angles are changed by events, it isn't really nescessary..

    This:

    " PlayerObject.Platform.VectorX > 0 and Press Left Arrow or PlayerObject.Platform.VectorX < 0 and Press Right Arrow"

    Sounds perfectly fine, but for something like that I'd use a state machine..

    Also just one variable a textvariable set to "left" while moving left, "right" while moving right..

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