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);
}
}