Moving elevator based on specified time limit

I’m trying to make an elevator move to a position based on the amount of time that’s on an in-game clock. It’s supposed to work similarly to a survival section in some games, where an elevator lift takes a specified amount of time to reach the bottom of a shaft.

As an example, I’ll use a time limit of 30 seconds. If 5 seconds have passed, the platform will be 1/6 the way toward its final position; if 15 seconds pass, it will be halfway; after 30 seconds, the platform should be at its final destination.

I’ve tried setting the speed of the elevator’s descent based on time rather than frames, but the speed is not consistent. Simply setting the speed to “(time limit) * Time.deltaTime” makes run faster the larger the time limit is; using the same equation but dividing the time limit by 60 (which I assumed would aid in making the time limit based on seconds) doesn’t seem to work, either.

Any pointers on moving an elevator based on a specified time limit would be much appreciated.


basically you could say something like:

var start : Vector3;
var end : Vector3;
var duration : int = 60;
private var startTime: float;

function Start(){
start = GameObject.Find("Start Point").transform.position;
end = GameObject.Find("End Point").transform.position;
startTime = Time.time;

function Update(){
var pos = (Time.time - startTime) / duration;
transform.position = Vector3.Lerp(start,end,pos);

something like this should do it (just tested, this works as desired)