- Home /

# 2d detect 360 (backflip) rotation on z axis?

Hi,

So I am making a 2d car game and am trying to implement scoring points based on the amount of backflips completed. I am not sure how to calculate (once the car has left the ground) if it has completed a full 360 degree turn anti-clockwise to then score a point. Does anyone know how I detect this?

Any help is greatly appreciated, thanks.

**Answer** by Teravisor
·
Jan 26, 2016 at 08:40 PM

It's so simple... I don't know how you didn't thought of that...

You can start counting it only when you change state from on-ground to airborne.

Each frame add to some variable that counts how much you turned while airborne.

Until you're out of airborne state. Then check which angle you've changed since 1. and score a point if you did do >=360 degree turn. Stop counting.

In order to check exactly counterclockwise and not just any angle, you need a simple math: angle between Vector(1,0) and Vector(x,y) is `Mathf.Atan2(y,x);`

(returns from -180 to 180 degrees in radians so multiply by Mathf.Rad2Deg and check when it goes from -179 to +179 or just use RigidBody2D.inertia) then subtract previous value of same angle to find angle change. Positive will be counterclockwise and negative will be clockwise.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.