Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best approach for game animation?

I have a course exercise in OpenGL to write a game with simple animation of a few objects

While discussing with my partner our design options we've realized we have two major choices for how the animation is going to work, Either

  • Set a timer for a constant interval, say 30 msec, when the timer hits, calculate where objects should be and draw the frame. or -
  • Don't use a timer, just a normal loop that runs all the time and in each iteration check how much time passed, calculate where the objects should be according to the interval and draw the frame.

What should generally be the preferred approach? Does anyone have concrete experience with either approach?

like image 520
shoosh Avatar asked Mar 07 '09 22:03

shoosh


People also ask

What is the best animation you can use in creating a game?

1. Adobe Animate - Our Choice. Verdict: Adobe Animate is powerful 2D animation software that allows you to create a game environment, integrate sound into it, and even share projects as augmented reality.

What FPS should game animations be?

It's commonly accepted that 60 frames per second is the rate at which animations will appear smooth.

What is an animation strategy?

Having a strategy with animation is the difference of giving a product that just looks good, to one of giving a product that's effective (and looks good). Anyone that pays for animation wants one simple thing, ROI (return on investment).

What is strongest point in animation?

Accents are the strongest points of motion in a scene: these are transitions that move at greater distance and/or speed. They're most important in dialog scenes, where the voice rises and falls in pitch and emphasis. Exaggeration is left to last for a reason.


1 Answers

Render and compute as fast as you can to get the maximum frame rate (as capped by the vertical sync)

Don't use a timer, they're not reliable < 50-100 ms on Windows. Check how much time has passed. (Usually, you need both delta t and an absolute value, depending on if your animation is physics or keyframe based.)

Also, if you want to be stable, use an upper/lower bound on your time-step, to go into slow-motion if a frame takes a few secs to render (disc access by another process?) or skip an update if you get two of them within say 10 ms.

Update (Since this is a rather popular answer)

I usually prefer having a fixed time-step, as it makes everything more stable. Most physics engines are pretty robust against varying time, but other things, like particle systems or various simpler animations or even game logic, are easier to tune when having everything run in a fixed time step.

Update2 (Since I got 10 upvotes ;)

For further stability over long periods of running (>4 hours), you probably want to make sure you're not using floats/doubles to compute large time differences, since you lose precision doing so and your game's animations/physics will suffer. Use fixed point (or 64-bit microsecond-based) integers instead.

For the hairy details, I recommend reading A matter of precision by Tom Forsyth.

like image 61
Macke Avatar answered Sep 21 '22 05:09

Macke