Question by
SylwiaLewinska · Jan 10, 2016 at 02:51 PM ·
rotationtransformquaternionslerpeuler
unwanted rotation in y axis
Hi. My motor makes wheelie on rear wheel on pressing shift. I'm trying to make it another wheelie in the opposite direction on pressing ctrl. I used the Slerp function. It works, however the motor also rotates in y axis. I get this unwanted rotation when I press either shift of ctrl to make wheelie. Motor rotates in y axis to face world z direction. I tried freezing this rotation through rigidbody but it doesn't work, and use different functions with quaternions and vector3 but with no results. I tried both in transform.rotation and transform.localRotation. Can sb tell what is the cause of this rotation?
this is my code:
In FixedUpdate
deltaRotation1 = Quaternion.Euler(-Wheelie, 0, flipRotate - transform.localEulerAngles.z + (MotorRotation));
deltaRotation3 = Quaternion.Euler(Wheelie, 0, flipRotate - transform.localEulerAngles.z + (MotorRotation));
deltaRotation2 = Quaternion.Euler(0, 0, flipRotate - transform.localEulerAngles.z);
myRigidbody.MoveRotation(myRigidbody.rotation * deltaRotation2);
The other part in Update:
if(shift)
{
transform.rotation = Quaternion.Slerp(transform.rotation, deltaRotation1, Time.deltaTime * 20);
}
if (ctrl)
{
transform.localRotation = Quaternion.Slerp(transform.rotation, deltaRotation3, Time.deltaTime * 100);
}
Comment