I have been trying to figure out a way for an enemy in my game to follow terrain, and therefore have a seperate x and z rotation, but for the y to look towards another object (the player). I have figured out that the best way to do this would be to make a plane from the x and z of my enemy and try to find the point where that crosses the x and z of my player. Then it will always look towards that area. However, I cannot find a way to get a point on a plane where two position points are true. Would anyone be able to help me out?
Cheers
Just rotate around the y axis by creating a quaternion, and setting the x and z values to zero (or whatever other value you want them to have)
var newRotation = Quaternion.LookRotation(transform.position - playerObject.transform.position);
newRotation.x = 0.0;
newRotation.z = 0.0;
transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime * turnSpeed);
Don’t follow the question really, but there is a bunch of good 3d math here
http://wiki.unity3d.com/index.php?title=3d_Math_functions
including line/plane intersections