I’m rewriting my character controller and I’m having problems with the rotation of the player. The degrees that it gets rotated to are perfect, but the Mathf.SmoothDampAngle doesn’t seem to be working correctly. It simply jumps directly to the target rotation.
In my ‘var zAngle’ statement, I’ve also tried removing the Time.deltaTime multiplication, but then I get no rotation, or perhaps just a very small amount.
Any suggestions?
#pragma strict
private var _rollTowards : float = 0;
private var _lastLocalPosition : Vector3;
var smooth = 0.3;
private var zVelocity = 0.0;
function LateUpdate () {
_rollTowards = (_lastLocalPosition.x-transform.localPosition.x)*60; // Target rotation
var zAngle : float = Mathf.SmoothDampAngle(transform.localEulerAngles.z, _rollTowards, zVelocity, smooth * Time.deltaTime);
transform.localEulerAngles.z = zAngle;
_lastLocalPosition = transform.localPosition;
}