0 Favourites

Sprite angle displayed differently

  • In my project I have different sprites. If I go into debug mode and look at the angles

    of 2 specific sprites one will go from 0 to -179 then skip to 179 and continue to 0 at

    which point it will go negative again and start over (it is spinning counterclockwise).

    i.e. never gets higher than 180 or lower than -180.

    However, the other sprite in question, when spinning counterclockwise, will start at

    0 and simply decrease to negative infinity. i.e. it goes to -4056 (or whatever).

    I need them to both act like the first example. I am not sure why they are working

    differently. If anyone can shed some light on this I would really appreciate it.

  • Sprite's in the debugger show their angle in the range of 0-360 so I assume it's variables you have?

    Sprite.Angle gives it's angle in the range 0 to 360.

    The angle() expression gives a value of -180 to 180.

    If you just subtract from a variable it will naturally go to negative infinity.

    This will convert any angle to the range of 0 to 360:

    (a%360+360)%360

    This will convert any angle to the range of -180 to 180

    angle(0,0,cos(a),sin(a))

  • Both those formulas might be nice to have as expressions.

  • I've been able to convert the angles to a 0-360 format using % and variable.

    Now I am stuck trying to get one sprite's bearing from another sprite. For example sprite A off

    the nose of sprite B would return 0 degrees irrelevant of the angle of Sprite B. 270 degrees

    off the direct left. 180 degrees off the tail. 90 degrees off the direct right.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Sprites in my debugger show their angle in 0-180. Negative when pointing up and positive for pointing down.

    My problem is that one sprite will continue to increase of decrease depending on direction. while the other

    will hit 180 and go negative or -180 and go positive to 0 then restart.

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