Hi !
I’m looking to find out if an object is rotating. Not to a specific number, or from one. Not between two numbers. Just simply rotating to any number and in any direction. Is that possible ?
Something like this but without the specific 90 degrees on y
if (myObject.transform.rotation.eulerAngles.y == 90)
Thanks !
Hyper
You could store every frame the oldRotation of myObject in a variable and, in the next frame, check if the variable has changed. Something like this:
Vector3 oldEulerAngles;
void Start(){
oldEulerAngles = myObject.transfrom.rotation.eulerAngles;
}
void Update(){
if (oldEulerAngles == myObject.transfrom.rotation.eulerAngles){
//NO ROTATION
} else{
oldEulerAngles = myObject.transfrom.rotation.eulerAngles;
//DO WHATEVER YOU WANT
}
}
if you have a rigidbody component attached the easiest solution is to check the angular velocity:
Hello Hyperactive,
You can use transform.Rotate to rotate your object like this, Apply transform.Rotate in Update :
function Update()
{
// Slowly rotate the object around its X , Y & Z axis at 1 degree/second.
transform.Rotate(Time.deltaTime, Time.deltaTime, Time.deltaTime);
}
Thanks
Ankush Taneja