so , im trying to get my character to rotate in order to look at the right direction but I cant seem to find a solution…
Also I know that i should evolve rotationSpeed or rotationSmoothing but I dont know how
using UnityEngine;
using System.Collections;
public class Player_movement : MonoBehaviour
{
public float speed;
public float currentSpeed;
public float jumpSpeed;
public float runSpeed;
public float gravity;
public float rotationSpeed;
private Vector3 v3_moveDirection = Vector3.zero;
private CharacterController controller;
void Awake ()
{
controller = GetComponent<CharacterController>();
currentSpeed = speed;
}
void Update ()
{
if (controller.isGrounded)
{
v3_moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, 0);
v3_moveDirection *= currentSpeed;
if (Input.GetButton("Jump"))
{
v3_moveDirection.y = jumpSpeed;
}
if(Input.GetButtonDown("A"))
{
transform.Rotate(0,180,0);
}
if(Input.GetButtonDown("D"))
{
transform.Rotate(0,180,0);
}
if(Input.GetButtonDown("Run"))
{
currentSpeed = runSpeed;
}
if(Input.GetButtonUp("Run"))
{
currentSpeed = speed;
}
}
v3_moveDirection.y -= gravity * Time.deltaTime;
controller.Move(v3_moveDirection * Time.deltaTime);
}
}
thats my code…
thanks in advance