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?
Vector3 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);
}
Vector3 newRot.y += currentTransform.localRotation.y + 5f;
— you're forming an Euler angle vector using the y component of a Quaternion. This is unlikely to have the geometric meaning you intend. If you're trying to inherit the yaw component of localRotation, thenlocalRotation.eulerAngles.y
is closer but still fraught at certain angles because of the way Euler angles jump around near gimble lock points. It's generally safer to work in quaternions for incremental rotations, and only use Euler angles for absolute orientation. \$\endgroup\$