How would you... is turning?

This forum is currently in read-only mode.
  • If you were making your own custom movement(top down), and you wanted to know when the object was turning left, or right... how would you set it up?

    My first thoughts were to have the current angle sent to a private variable, and then compare that variable... if its less than current, you have a right turn... etc.

    Seems a little complicated, especially on the timing.... any thoughts on a better way?

  • It's pretty straightforward with the "is clockwise" system condition. I through the anglediff in there to make a threshold so that the Sprite isn't always thought to be turning.

    + Sprite: Pick by anglediff(.angle, 'oa') Greater than 1
        + System: Angle Sprite.Angle is Clockwise from Sprite ('oa')
        // turning right
        + System: Angle Sprite.Angle is Anticlockwise from Sprite ('oa')
        // turning left
    + System: Always (every tick)
    -> Sprite: Set 'oa' to.Angle
    [/code:2zibx2e6]
  • At the end of the event sheet set a pv called "last angle" to .angle. Then use the system compare: "angle is clockwise/counterclockwise of" to check it against the current angle. If the current angle is clockwise to the last angle then it turned right.

    Edit: Rojo beat me to it.

  • Thanks guys!

    That anglediff, does sound perfect for the timing issue.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh wow this is one of those times where placement of the events really matters.

    If you set the value before you do angledif, nothing will happen.

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