BEGINNERQUESTION about Quaternion and axis restriction

Hi I am a beginner and have a question, I use the quaternion funktion to let the turret of my tank rotate to the point where the mouse looks , but i want that the turret use only the y axis ( i want the x seperate for the cannon ) can i declare this in the quaternion function or it is not possible ?

Turrettarget is a Vector3 position from a camera raycast

var rotate;
rotate = Quaternion.LookRotation (Turrettarget - Turret.transform.position);
Turret.transform.rotation = Quaternion.Slerp (Turret.transform.rotation, rotate, rotationmodifier * Time.deltaTime );

can someone give me an advice how I restrict the x,z axis in this function ?

thanks for help :slight_smile:

Well this is a slightly dodgy way but it is the easiest. What you can do is just set the x and z axis to 0 at the end of every frame. You should use put in something like

rotation.z = 0;
rotation.x = 0;

in the LateUpdate() function (instead of in Update). LateUpdate is executed after Update() is done every frame

Thanks thats help a lot , so i become a other idea for the turret movement that i can show now . :slight_smile: