var dir = PlayerMovement.playerTransform.position - transform.position;
Quaternion LookAtRotation = Quaternion.LookRotation(dir);
Quaternion LookAtRotationOnly_Y = Quaternion.Euler(transform.rotation.eulerAngles.x, LookAtRotation.eulerAngles.y, transform.rotation.eulerAngles.z);
transform.rotation = LookAtRotationOnly_Y;
using UnityEngine;
public class Rotation : MonoBehaviour
{
public float xAngle, yAngle, zAngle;
public GameObject objectToRotate;
void Awake()
{
//change position here to see object as want
objectToRotate.transform.position = new Vector3(0.1f, 0.0f, 0.0f);
objectToRotate.transform.Rotate(90.0f, 0.0f, 0.0f, Space.Self);
}
void Update()
{
objectToRotate.transform.Rotate(xAngle, yAngle, zAngle, Space.Self);
}
}