Mathf.SmoothDampAngle Not Smooth

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;
}

Just stumbled upon this question, so I’m sorry for the 3 year late reply! But incase it can help others, or even you still, you shouldn’t put *Time.deltaTime for the “speed” parameter in SmoothDamp or SmoothDampAngle, because this parameter is actually looking for the time between it’s A point/rotation and B point/rotation, not the update amount like with MoveTowards.

So 0.3Time.deltaTime is a very small time, so it’s going to go very quickly! If you replace smoothTime.deltaTime with just 0.3 (or your smooth float property) then it will be smooth, and take about 0.3 seconds (about, not exactly) to complete the rotation.

I hope this can help you, or any other unity dev that might fall here!