# Calculate one lap completion Unity3d

Hii all…

I am having one circle sprite with circle collider. I am continuous rotating this circle on z axis by using :

``````transform.Rotate( 0  , 0 , speed * Time.DeltaTime);
``````

Now i want to increment my score when circle completes rotation to 360 degree.

For that i have tried :

1. ``````transform.rotation.z == 360
``````
2. ``````transform.Eulerangles.z == 360.
``````

But this will not work as circle is continuous rotating with different speed.

So this condition will not satisfied. So what can be the another way to find complete rotation completion.

Thanks.

@Veldars’s code is also fine. If you want to check for EulerAngles then you can try this.

``````using UnityEngine;
using System.Collections;

public class Rotator : MonoBehaviour
{
private float currentRotation;
private float speed = 50f;

void Update ()
{
currentRotation = transform.rotation.eulerAngles.z;

if(currentRotation>360-speed * Time.deltaTime || currentRotation==360)
{
Debug.Log("===Complete");
}

transform.Rotate( 0  , 0 , speed * Time.deltaTime);
}
}
``````

I think you can create some variable…

``````private float _prevRotation = 0;
private float _actRotation = 0;

void Start() {
_prevRotation = transform.rotation.z;
}

void Update {

_actRotation = transform.rotation.z;
if (_actRotation - _prevRotation >= 360) {
// Do what you want...

// Reset prevRotation
_prevRotation = transform.rotation.z;
}
transform.Rotate( 0  , 0 , speed * Time.DeltaTime);
}
``````

I hope it’s what you are looking for.