Intro to 3D Game Development

0 of 193 lessons complete (0%)

Scripting Part 1: Moving Objects

Timing the Animation

You don’t have access to this lesson
Please register or sign in to access the course content.

Right now, we can change how far the chest goes, and the speed (how far it goes each frame), but if we wanted to make it last a specific number of seconds, we would have to do some guess-and-check approximation. Also, if anyone’s game is running slower, that will also slow down this animation.

What we would like to do instead is to be able to tell the program how many seconds we want the animation to last, and how far the chest needs to go, and have it calculate for us how much to move the chest each frame.

We can think of this as a percentage. When the time is 50% done, we would like the animation to be 50% done as well.