Hi,
I have tried many variatons of code,
inspired from what I had seen on the Unity Ansers forums,
and elsewhere, but I haven’t come up with a solution yet.
What I need is: an object that points at the player continuously, but that only rotates around its y axis.
I have tried to clamp the transform.LookAt function but without success.
I have also tried various other ways to achieve this, but I got totally confused with the quaternions and euler angles.
I would appreciate a lot , if somebody could point me to the right direction.
That won’t actually work right, because transform.rotation is a quaternion, and setting .x and .z doesn’t do what you think it does. Aside from Jesse’s solution, you can do
var lookatPos = targetPos;
lookatPos.y = transform.position.y;
transform.LookAt (lookatPos);