I am using a character controller with a modified version of the PlayerController.js script. They player isn't able to move regularly on terrain based slopes. If your moving up and attempt to turn around, the players rotation isn't updated until x amount of time,
Here is the block that moves the player:
// We store speed and direction seperately,
// so that when the character stands still we still have a valid forward direction
// moveDirection is always normalized, and we only update it if there is user input.
if (targetDirection != Vector3.zero)
{
//If we are really slow, just snap to the target direction
if (moveSpeed < walkSpeed * 0.9 && grounded)
{
moveDirection = targetDirection.normalized;
}
// Otherwise smoothly turn towards it
else
{
moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000);
moveDirection = moveDirection.normalized;
}
}
Now, When I get rid of the `if (targetDirection != Vector3.zero)` condition and everything else except this:
moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000);
moveDirection = moveDirection.normalized;
the player is then able to move around smoothly on the hills, except now the player's character model's orientation doesn't update correctly.
Any suggestions?