Detection of sprite rotation

This forum is currently in read-only mode.
From the Asset Store
Detects any kind of ad blocker. Very easy implementation into already existing projects
  • (Yup, me again)

    So, sprite X is rotating. It can rotate clock and counter-clockwise. I am trying to figure out how can the engine detect that rotation and perhaps also detect in which side its rotating.

    On example:

    Lets say a spaceship is flying. now he rotates. When he rotates i want him to "lean" in left or right side. This is achieved by changing the animation for a moment.

    The problem is - i am trying very hard and i cant find a method to trace the rotation or its direction. Same for tracing if the angle is increasing or decreasing or even if its changing in general.

    I though that i could perhaps use PV and set it to angle. Then with events monitor if the PV is going up or down and attach this as a condition for the animation change but theres also no "increasing"/"Deacresing" condition for PV neither.

    I am playing in my mind with an idea to create a "phantom" sprite attached on top of the original, with rotation behaviour but with faster rotation speed.

    So lets say the Main Sprite angle is 180 and Phantom Sprite angle is 180. Now the Phantom sprite is turning right so his angle increases. In first secund the angle of Phantom is now, lets say, 250. When Main angle is still around 180. Both are turning but the angle of Phantom is higher then the angle of Main.

    This is when i can make it a triger. So:

    If system value compare Main.Angle lower then Phantom.Angle then -> change animation to "lean right"

    If system value compare Main.Angle greater then Phantom.Angle then -> change animation to "lean left"

    But i havent tested this yet. Its just an idea. Maybe not that complex but also far from elegent and simple (if it works that is).

    Also this preety much doubles each and every moveable-rotatating sprites in the game. needlessly. So if theres a huge battle going on and theres 50 enemies. Each made out of 3 linkes to each other animated sprites + 50 extra Phantom sprites... well, you got the idea. messy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • curAngle = current angle

    oldAngle = old angle

    dAngle = angle difference

    dAngle = oldAngle-curAngle

    Basically store the angle in oldAngle to use for next calculation. You can also checks every 100ms or so (not every frame), compare the angle 100ms ago and now, then you can find out where it is leaning from the difference. You can also apply different levels of tolerance; negligible angle difference shouldn't change the angle, value between 1 and 15 would result in slight leaning, value above 15 into more powerful leaning etc.

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