Move a character from A to B within X seconds

Hi there,

I encountered problems with that, so basically I've a queue of vector4 with the fourth dimension used for the time, and I want my character to follow the path. But I want to do it with a character collider in order to ensure that the character is on the floor, so by the use of SimpleMove. dataSet is an interface for my queue The problem is that my character go too far.

Could you help me please ?

void Update()
{
    if (dataSet.Size() > 1 && Time.time >= endPoint.w)
    {
        transform.position = endPoint; // Ensure that the previous move was well done (for instance if the character is stuck onto a wall, etc.)
        endPoint = dataSet.GetAndErasePeekVector4() + (Vector4)offset; // The new endpoint
        transform.LookAt(endPoint);
        speed = Vector3.Distance(transform.position, endPoint) / (endPoint.w - Time.time);
        direction = (Vector3)endPoint - transform.position;
    }
    characterController.SimpleMove(direction*speed);
}

Hi,

You'll find this answer and forum reply with fully working project maybe useful:

This project features iTween library and is perfect for what you seem to be willing to achieve. You can animate over a time period or with a speed parameter. it's really flexible.

To be precise, you would simply have a call like so:

iTween.MoveTo(theGameObject,theTargetPosition,theDuration);

You can find the full doc here

Bye,

Jean