Easing character controller movement

Hi lovely unity guys again,

I need some help with easing character controller movement. I’m developing an iPad app with a character moving with a finger swipe. Basically, it moves when i wipe my finger across the screen. How do I achieve an easing movement before the character eventually comes to a stop. I’ve stripped down some of the codes but the character movement is something like this.

private var character : CharacterController;
var movement : Vector3 = Vector3.zero;

movement = thisTransform.position - targetLocation;
movement *= Time.deltaTime;
character.Move( movement );

I reckon there should be some of a smoothing script? please correct me if i’m wrong.

Thanks guys. Appreciate it.

Rgds,
jser


updated code:

var startspot : Transform;
var endspot : Transform;

function Start () {
	SmoothMove(startspot.position, endspot.position, 5.0);
}

function SmoothMove (startpos : Vector3, endpos : Vector3, seconds : float) {
	var t = 0.0;
	while (t <= 1.0) {
		t += Time.deltaTime/seconds;
		transform.position = Vector3.Lerp(startpos, 
                                   endpos, Mathf.SmoothStep(0.0, 1.0, t));
		yield;
	}
}

You are looking for ease in ease out, which is very easy to accomplish. You don’t only use Time.deltaTime, but you have to multiply it with a speed. This speed is varying while moving. I found a reference for you, but you could easily look for ease in ease out

Update
The biggest problem you’re having, is that you call your function only once at Start(). Instead, you should call it everyframe, because else your character only moves a little piece over deltaTime (which is about 0.002 seconds). Try using this in the Update() instead. Here you can read about all overridable methods in a MonoBehaviour.