I'm using Quaternion.Lerp
to rotate a joint with a certain angle, but when I use the below code I find the joint rotating very far although I specified it to rotate with only 5. Any thoughts please?
newRot.y += currentTransform.localRotation.y + 5f;
blendWeight = 0;
if ( blendWeight < 1)
{
animationRotation = currentTransform.transform.localRotation;
newRotation = Quaternion.Euler(newRot.x, newRot.y, newRot.z);
blendWeight += Time.deltaTime/0.9f;
currentTransform.transform.localRotation = Quaternion.Lerp (animationRotation,newRotation, blendWeight);
}
where newRot is a Vector3
If you want to add 5 degrees to y, you must use eulerAngles and not directly rotation (which il a quaternion). Generaly speaking you should never set the xyzw components of a quaternion.
If you want y slowly rotates an object, consider using RotateTowards (for a given target orientation) or transform.Rotate (for a given speed).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.