- Home /
How to change transform.Translate over a certain amount of time
Hi I was wondering how I can change a box's speed over time. EX: I have a box and it is moving at a speed of 5 on the x axis, I need to speed the box up to 10 after 5 seconds. How do I do this? Thanks !!
Answer by You! · May 28, 2012 at 04:13 AM
var mover : Vector3 = Vector3.zero;
function Update()
{
mover = Vector3(5,0,0);
if(Time.deltaTime <= 5)
{
mover.x += 2* Time.deltaTime;
}
else
{
mover.x += 5
}
move();
}
function move()
{
Transform.Translate(mover * Time.deltaTime,Space.World)
}
Answer by lblaz7 · May 28, 2012 at 05:53 AM
sorry I mislead you. So what happens is that I have a box that drops out of a plane. The plane is moving and every time you press the space bar the box drops from it. The box has a movement downwards, so when it drops it hits the ground. I need to find a way so that when the space bar is pressed after, say 10 seconds of gameplay, the box instead of moving downwards at a speed of five, gets moved downwards at a speed of 10, per say.
Does that make sense kind of?
Could you edit your question so that it is worded like that? Doing so would allow other answerers to be less confused as well!
Could you also post your code in the question? This would allow for me (and others) to actually see what is happening and be able to help better!