- Home /
Question by
Pauls · Nov 24, 2012 at 12:04 AM ·
charactercontrollertimetime.deltatimecharacter.move
Multiply deltaTime to arrive at point2 in 1.5 sec ?
Hi,
how can i ask a character to move from point1 to point2 in only a defined period of time? For example i want him to go to some direction and arrive at point2 in exactly 1.5 second?
I have tried with the following code, but the character goes too fast, i throw a sphere up in the air and when the sphere starts coming down, i calculate the time the sphere needed to go up, which is 1.5 sec ("launchtime"), and try to make the character arrive after 1.5 sec at the destination point, but he goes too fast and arrives before the sphere lands.
Here is the code :
character.Move(dir.normalized * (Time.deltaTime * (launchTime/Time.deltaTime)) );
Would you know how to calculate this?
Thanks
Comment
Best Answer
Answer by Pauls · Nov 24, 2012 at 07:39 PM
So, here is the solution :
var distPerFrame = distanceTotal * Time.deltaTime / launchTime;
character.Move(dir.normalized * distPerFrame );
;-)