i have 2 cubes in my one is static that looks at the other object so when i move the other object the first cube should rotate it self to the other one but the problem is i want it to do this only in the Z axis or up and down only = 1 axis , but when ever it start looking the x,y,z all change while i want them all to remain 0 except the one that looks up and down at the other cube i tried something to limit the Y and it worked but it doesnt work with Z , any help ?
Please post some code and we’ll be able to help better. We don’t even know what language you are using.
I would say that use the same logic as what is working for the Y axis, but in the parameters 0 out the Y information, and put the information in the Z’s place.
never mind , my problem was that when my 1st cube starts to LookAt(Cube2) all the axis start to change (X,Y,Z) all i wanted is the Z axis only , i fixed this using
var relativePos = Vector3 Cube2.position - Cube1.position;
var rotation = Quaternion.LookRotation(relativePos);
Cube1.rotation = rotation;
thanks for your help though