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?
Now it doesn't update unless keys are pressed (meaning you have to let go and press again for it to update.) I pasted my Movement function above. I didn't want to paste my controller script, for it is way to big. :D
– SrBilyonNote: You could always paste to pastebin.com for large files
– StatementEh, I just realized how stupid it was of me to write
– Statementtransform.LookAt(transform.position + transform.forward);:) If course that's where the transform already is looking. D'oh.