Player Movement:
public float PlayerSpeed = 1.9f;
public CharacterController cC;
public float turnCalmTime = 0.1f;
float turnCalmValocity;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
PlayerMove();
}
void PlayerMove()
{
float Horizontal_Move = Input.GetAxisRaw("Horizontal");
float vertical_Move = Input.GetAxisRaw("Vertical");
Vector3 direction_Move = new Vector3(Horizontal_Move, 0f, vertical_Move).normalized;
if(direction_Move.magnitude >= 0.1f)
{
float target_Angle = Mathf.Atan2(direction_Move.x, direction_Move.z) * Mathf.Rad2Deg;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, target_Angle,ref turnCalmValocity, turnCalmTime);
transform.rotation = Quaternion.Euler(0f, angle, 0f);
cC.Move(direction_Move.normalized * PlayerSpeed * Time.deltaTime);
}