Rotete player towards direction of movement

Hello Everyone!

I have a slight problem, for some wierd reason my player model is refusing to rotete towards direction of movement. I would really apreciate if someone could take a look at code below and give me some tips as of why this is happening.

using UnityEngine;
using System.Collections;

public class CharacterMovement : MonoBehaviour
{
    public float moveSpeed = 5;
    public float jumpSpeed = 20;
    public float gravity = 9.8f;

   

    Vector3 moveDirection;

    CharacterController controller;


    void Start ()
    {
        controller = GetComponent<CharacterController>();

    }
   

    void Update ()
    {
        moveDirection = new Vector3(Input.GetAxis("Horizontal") * moveSpeed, 0, Input.GetAxis("Vertical") * moveSpeed);
        moveDirection = transform.TransformDirection(moveDirection);

        if(Input.GetButton("Jump"))
            moveDirection.y = jumpSpeed;
           


        moveDirection.y -= gravity * Time.deltaTime;
        controller.Move (moveDirection * Time.deltaTime);
   
    }
}

I don’t see any rotation in your code

Unity Doc for Rotation of an gameobject

or

1 Like

Oh my god! Thank you !!!

I have just learned how to use euler angles to rotate the model :))