player isnt moving based on rotation unity code example
Example 1: hwo to prevent rotation after hitting an object in unity
private void OnCollisionEnter(Collision collision)
{
GetComponent<RigidBody>().freezeRotation = true;
}
Example 2: look rotation only on y axis in unity
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;