Prevent keyframe interpolation in imported model animation in Unity
I made first person model in blender. It also has animations in it.
Most of animation works fine, but in some cases, Unity's keyframe interpolation makes wrong result.
Note that animation was made by 60 frames per second in Blender.
To explain my problem, you have to see my model:
As you can see there are two magazines. Each named Mag1 and Mag2 and Mag1 is the magazine that attached to the gun.
Mag2 is always located very bottom of the screen so that it is impossible to see, except reloading animation.
While reloading, first pull out the mag1 from the gun and put in the mag2 to the gun. And here is the trick, after mag2 is attached to a gun, hand put the mag1 somewhere, maybe magazine pouch.
Anyway as soon as mag1 disappeared from the screen, it switches mag1 and mag2 immediately at only single frame. So mag1 is now move back to the gun and mag2 is also reloated to bottom.
In Blender, it seems nothing wrong but in Unity is quite different. As soon as mag1 disappeared, it doesn't switched immediately and it moves smoothly animated so I can see that magazines were moved. I'm pretty sure that this happens maybe Unity interpolates keyframes.
I already turned off Animation Compression option and resample curves, but still won't worked.
This is the video that I made to explain my situation: https://www.youtube.com/watch?v=7aew959ejL4&feature=youtu.be
Is there a way to "turn off" that interpolation? I want to disable it only that frame. Unity doesn't allow me to edit animation clip, so I just duplicate animation clip and change the option(I don't know what it called) to "Flat" and use that clip instead, but still have same problem. (Note that it wasn't easy because Unity doesn't show me the animation if I duplicate and modify it)
I struggled this issue almost a year and still figuring out how to fix it, and I think it's time to solve it. Any advice will very appreciate it.
Answer by theANMATOR2b · Jun 14, 2018 at 06:48 PM
This has something to do with framerate rather than animation interpolation,,, I think. Since the game is running at faster than 60 fps - it is interpolating the 59th and 60th frame in the animation when the magazine is being moved out of frame in 1 animation frame. If you clamp the frame rate at 60 fps I believe this visual error would not happen.
Question - why are the magazines swapping locations at the end of the animation? Why not use the two magazines (give them similar traits) so they do not need to be swapped?
Other solution - have the two magazines occupy the same location on the same frame, at the same time.
I'm sure there are other equally qualified solutions, those are the ones I think can work with relative ease.
Your answer
Follow this Question
Related Questions
How to disable animation interpolation to imported animation? 0 Answers
Altering animation curves via script 2 Answers
How can I create animation keyframes using C# scripting? 0 Answers
How to make an Animation layer not set curve parameters? 0 Answers
yield new waitforsecond(1) counter time varying after ludo dice roll. 0 Answers