I want to track my objects rotation. I will give an example so you can understand.
I want to rotate an object by an amount in any direction. Once it hits that amount, it stops.
The way I have it set up is basically:
if(rotatingObject.transform.rotation.eulerAngles.y < 90)
{
rotatingObject.transform.Rotate(Vector3.left * speed * Time.deltaTime);
}
The issue at hand is that rotation is from 0 to 360 so sometimes if I rotate left or right it goes from 360 to 0 and I have to duct tape the code so that it works the way I want to.
What I want to know is if this is possible. I will pseudocode it a bit
Have an integer of float that is the rotation being track by a positive value. So lets say the object rotates by 1 this will += 1 to that integer or something like that. Here is an example below.
public GameObject rotatingObject;
public float rotationTracking;
public float rotationGoal;
void Update()
{
rotateObject();
}
void rotateObject()
{
if(rotationTracking != rotationGoal)
{
/*I know this next line wont make much sense but it will convey the idea I am trying to get across and what i'd like to do
rotationTracking = rotatingObject.transform.Rotate(Vector3.left * speed* time.deltaTime);*/
rotatingObject.transform.Rotate(Vector3.left * speed* time.deltaTime);
}
}