Follow object by Transform.Rotate

Hello! I have two objects - first is Player and second is Enemy. Enemy must look at Player, but I can’t set 3 axis - so I can’t use “transform.LookAt”. I need only to set y axis. So - I have idea to do that by “transform.Rotate”. And maybe raycast to detect Player… You have idea to code that?

Thanks in advance and sorry for my english :wink:

You can use Transform.LookAt and immediately afterwards set the eulerAngles of the axis that the transform should not rotate around to 0.

transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);