What is best practice when exporting looping animations for use in a realtime 3d game engine?
for example: looping walk cycle (frame 0 and frame 100 are identical)
1. set start frame to 0, end frame to 100, export
or
2. set start frame to 0, end frame to 99, export
Option 1: duplicate frame data but curves placed end on end will be continuous
Option 2: no duplicate frame data.
In maya (for example) while animating, it makes sense to set the playback range one frame less to avoid duplicate frame being played while previewing the animation, but when exporting animations for realtime 3d engines do you want to export a full continuous curve?
Replies
totally not the answer i was hoping for as now I have a bunch of re-exporting to do. My animations are all full length, and our outsourcer's are all one frame short. Although I can't notice any skipping in engine...
I have done this for pre-rendered sprites before because you obviously don't want duplicate sprites in a sequence. But in a 3d game engine where fps is not fixed, isn't the game basically sampling values from the curve rather than playing specific frames? eg. allowing for example slow motion playback without loss of smoothness or playback at 60fps despite animating in 30fps. So if I make an animation in which frame 0 and 100 are identical, the length of the animation curves on the timeline is 100 frames. If I export 0-100, the length of the curve is 100 but if I only export 0-99, then the length of the curve is only 99. The portion of the curves that exist between frames 99 and 100 are lost and cannot be sampled, leading me to think this would cause the playback time to be 1 frame shorter and also not smooth (for example causing the first foot contact on a walk cycle to appear heavier). This incompleteness of the curve data would seem especially serious if the frame rate was set low while animating. Maybe my understanding of how realtime engines handle animation is entirely mistaken.
What will register as a pop is if your curves don't loop properly. In maya you turn on pre and post infinity curves and they should flow seamlessing together.
https://kakes3d.wordpress.com/2010/07/28/looping-and-copying-keyframes-in-maya/
I trust with both of your experience that you are correct. But do you know what's going on the engine to make this correct? I can't wrap my head around how this could be correct when a portion of the full curve is clearly missing from the data (and i guess cannot be interpolated). Imagine an extreme case, where you've animated a six frame walk cycle (for example for prerendered sprites) but now you want to reuse that in a realtime engine running 60fps. Frames are as follows:
0: left foot forward, right foot back
1: left step,
2: legs pass,
3: right foot forward, left foot back
4: right step,
5: legs pass again,
6: left foot forward. right foot back (same as 0)
If you export frames 0-5, left foot forward to back motion takes 3 frames (3-0), right foot forward to back motion is incomplete and only takes 2 frames (5-3). How does this work? How does the engine interpolate the motion between frames 5-6?
For Unity you do want to keep the duplicate frame at the end. The example below is a one second animation slowed down to 10 seconds in Unity. Notice the orange box has a hitch. @kwyjibo your instinct is correct. The last frame is only used for interpolation. It's tricky to understand because 0 - 24 is 25 frames. So it should be longer than one second. But remember frame 24 has transform key data, but no time duration. So it's really 0 - 23.999.
In Unity's Animation panel, the blue box is 1 second and the orange box box is 0.96 seconds. So if you require precision timings, keep the frame.
Another tip with Unity is that after you turn on Loop Time, and your animation is missing the last frame, you can also turn on Loop Pose and it will add it in for you.
If you are using Unreal I still recommend keeping the frame. Most game engines these days allow you to crop the time segment so it will still cause no harm.
To add to what Monster was saying, a frame is, the sum of it's parts. It is all of the information between the last frame and the next. It's easy to think of it as a single tick mark on a timeline but it's not.
It's like a ruler, a cm isn't just as wide as the thin black line under the 1, it's all of the space/time between 0 and 1.
When you shave off a frame it's not just a tiny sliver, its a chunk of time. Not only do you lose that one pose, but you lose the info that gets it from the last pose to the missing pose.
But yea it really doesn't matter, its an issue has been dealt with long ago, you just need to pick a direction and flip the right settings in the engine.