I 'm using a Quaternion.Slerp to rotate an object, and I need a way to set its X any Y rotations to be equal to its parent object. The Z rotation is the only one I’m trying to change. My code looks like this;
var smooth = 2.0;
var angle = Quaternion.identity;
var tiltAngle;
function Update(){
angle.eulerAngles = Vector3(0, 0, tiltAngle);
transform.rotation = Quaternion.Slerp(transform.rotation, angle, Time.deltaTime * smooth);
}
The variable tiltAngle is a float that I’m using to control the Z rotation, it’s not important.
Its the two zeros in the line “angle.eulerAngles = Vector3(0, 0, tiltAngle);” that I need to replace to the parent’s rotation. How can I do this?