Rotation Lerp

Hi, I’m making an object rotate around it’s axis by using LookAt at an object that is on your mouse position when clicked. All in all this works pretty solid, except I want it to gradually go to the that rotation instead of instantly be there.

Now I even managed that through Quaternion.Lerp, what the real problem is that I want it only to rotate around it’s X axis. The code I’m using right now is this:

					var rotation = Quaternion.LookRotation(Target.position);
					ThisTransform.rotation = Quaternion.Lerp(ThisTransform.rotation, rotation, Time.deltaTime * speed);

Simply set the rotations you don’t want to alter back to 0:

void Update(){ 
    var newRotation = Quaternion.LookRotation(Camera.main.transform.position - transform.position).eulerAngles;
    newRotation.x = 0;
    newRotation.z = 0;
    transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(newRotation), Time.deltaTime);
    }

This will only rotate the y-axis

More on this here:

try something like this:

var rotation = Quaternion.LookRotation(new Vector3(Target.position.x, ThisTransform.position.y, Target.position.z));

I use C# so maybe the “new” is misplaced.