How do I Detect if an object has made a full rotation

0 favourites
  • 2 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • Greetings all! I'd like to detect when an object has made a full rotation and am trying to figure out the best way to do that.

    The context is a physics object which you knock into the air, and if you get some spin on it I'd like to assign points every time it does a complete 360 rotation.

    My initial thought was to detect the object's angle as soon as it gets airborn, then listen for every time its angle is once again equal to that starting angle, but since the angle is a float it will never be exactly equal (that method also doesn't take into account if it switches spin directions for whatever reason)

    Other suggestions?

    Edit: note I'm using the Chipmunk plugin for the physics object

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Keep track of the angle change as soon as the object get airborn. You will need two instances variables, "lastTickAngle" and "deltaAngle".

    Object gets airborn -> set lastTickAngle to object angle, set deltaAngle to 0

    Every tick -> Add (lastTickAngle - Object angle) to deltaAngle

    If Abs(deltaAngle) >= 360 -> Add point, add 360 or subtract 360 to deltaAngle

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