Rotate to look at object, but x and y axis has to be static,How to make a game object look at another game object?

I can make the object look at another object, but the problem is that x and y has to be static(should not change) and z has to change .
Please don’t ask why it’s the only way my game will work.

thx for help :),I can make the object look at another object, but the problem is that x and y has to be static and z has to change .
Please don’t ask why it’s the only way my game will work.

thx for help :slight_smile:

Good day.

I just imagnined a solution for you. Lets say your object is called “Eyes”.

Make an empty object (only a transform) called "FakeEyes, at the same icheracy position (i mean children of the same parent), same rotation and same position. Now make this FakeEyes look at the desired objective.

Now, just need to “copy/paste” the rotaitionZ to “Eyes” with

Eyes.transform.rotation.EulerAngles.z =  FakeEyes.transform.rotation.EulerAngles.z;

And then ,make the fakeEyes rotation equal to eyes rotation so the next time you need to do this calculation, it will be ready :smiley:

Cappicci? XD

Bye!

PD: Maybe code have some typing error, (capital leters, etc… XD)