# how to count down my player's flips ?

hey guys , so i’m using the script down below to make my player to look at a target only on Z.
i need to know how to count my player’s rotations around z axis when he performs a complete 360 degree rotation.and store his complete rotations number in an int value maybe.
thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

``````public class looking : MonoBehaviour
{
public float speed;
public Transform target;

void Start()
{

}
void Update()
{

Vector3 direc = target.position - transform.position;
float angel = Mathf.Atan2(direc.y, direc.x) * Mathf.Rad2Deg;
Quaternion rotationi = Quaternion.AngleAxis(angel, Vector3.forward);
transform.rotation = Quaternion.Slerp(transform.rotation, rotationi, speed * Time.deltaTime);

}
}
``````

i think that you can use eulerAngle.

if player performs a complete 360 degree, eulerAngle.z must be 360 to 0 or 0 to 360

(or -180 ↔ 180… etc. i forgot exact values.)

if your player rotate in only a positive direction, you can try like this

``````if(startNewCircle && transform.eulerAngle.z > benchmark) {
count++;
startNewCircle = false;
}

if(transform.eulerAngle.z < preZ) {
// it means that eulerangle z changes from 360 to 0
startNewCirle = true;
}

preZ = transform.eulerAngle.z;
``````

i guess there is some exacter way, but i think it is the simplest way!

tanks man , your answer kinda works , but didn’t know what preZ and benchmark do? and what value should i assign them?