How to detect a 2d car doing flips (Backflip or Frontflip)

Hello,

I tried to calculate the rotation of the transform (transform.rotation.z or transform.eulerAngle.z) from when my car get off the ground to when it hit back the ground.

But my problem is that when my car do a complete rotation tranform.eulerAngles.z always goes from 360 to 1.

I would have expect that the rotation just add the whole time the scene is running.

What I mean is that if my starting rotation was 0 and my car jump and do 3 backflip, then his rotation is now something like -1080.

But when rotation exceed 360, it goes back to 1

Can anybody have and idea to calculate the complete rotation ? Help would be highly appreciate Thanks !

The transform’s rotation member certainly isn’t cumulative - that wouldn’t make any sense in most cases. Why not just track the cumulative rotation change yourself in an Update function? Just calculate the delta angle change between the current frame and the previous frame and add it to your own internal variable.

Jeff

Wow thank you to point me delta function , it solve my problem !

Is there any built in api for this?
Or I’ve to do this manually?

1 Like