How do I compare angles?

0 favourites
  • 5 posts
  • I'm trying to create a game that simulate a weighing balance. First I tried using the Physics behavior, but I gave up because I did not know how to adjust parts of the weighing balance (bar, plates, base, etc.). I am now using the Rotate behavior to simulate this and I need to compare the angle to stop the rotation (speed = 0). This action does not exist for the object, so I decided to use the system action: "compare two values". However, it did not work. Any help? Thanks.

  • I found a better solution: anglelerp (lerp(self.Angle, x, dt). But the question remains: why can not compare angles?

  • I think the anwser is simple: you cannot define one unique angle, an angle of 90 is as valid as an angle of -270, or even 450, so comparing angles directly is not that meaningful and depending on how some parts of the engine works, the result can be unexpected.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could normalize the angle to a range of (-180,180) with angle(0,0,cos(a),sin(a)) before comparison.

    Or you could use the sprite condition "is within angle" or "is between angles".

    Or you could use the anglediff(a,b) expression to find the angle difference in the range of (0,180).

  • Or you could use the sprite condition "is within angle" or "is between angles".

    I tried this but not worked and I don't know why.

    R0J0hound: I'll make some tests with the others suggestions. Thanks.

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