rotate towards target only on Y axis???

how do i rotate an object towards the player only on the Y axis?

  • not using Transform.lookAt.

What’s wrong with Transform.LookAt? If you want to rotate towards an object on only one axis, all you need to do is remove any factor that would cause it to rotate on any other axis.

In this case, you need to remove the y-axis height difference between the two positions.

public void RotateTowardsYOnly(Vector3 targetPos)
{
    targetPos.y = transform.position.y;
    transform.LookAt(targetPos);
}

This will remove the difference in height, and so it will rotate perfectly around the y axis!