I'm trying to replicate Silent Hill's mechanic where if you press a button, the character does a 180, but instead of getting a smooth turn around, my character is snapping from one rotation to another.
This is the code I have so far:
if (Input.GetKeyDown(KeyCode.Tab))
{
transform.Rotate(0f, 180f, 0f);
}
I also have a Sprint(); function and I want to disable this feature if the character is sprinting. Here's the code for that:
private void Sprint()
{
float newTurnSpeed = _turnSpeed - 1.4f;
vertical = Input.GetAxis("Vertical");
horizontal = Input.GetAxis("Horizontal");
Vector3 direction = new Vector3(0f, 0f, vertical);
Vector3 movement = transform.TransformDirection(direction) * _sprintSpeed;
transform.Rotate(0f, horizontal * newTurnSpeed, 0f); //add the new turn speed
isGrounded = _characterController.SimpleMove(movement);
}
Any help is appreciated!