- Home /
How do you call a specific frame in an animation?
I want to create a script that instantiates prefabs at very specific points in an animation. A baseball is instantiated when a pitcher's arm is at its straightest, or a flare particle system is instantiated in the same moment where match and matchbox connect in an animation. I have some limited experience with hit frames in other engines, but nothing that helps me out here.
I have figured out how to set keys in a mecanim AnimationCurve, and I'm guessing I'm on the right track here. But, I can't figure out how to access those keys by script. What I really want is something along the lines of
//if specific point/key of animation is reached
//instantiate prefab
Any help?
Are you doing the animation in Unity or an External Program?
The old system used time (or 0-1% normalized time) ins$$anonymous$$d of keyframes. If you wanted keyframe 30 out of 45, you checked if normalized time was 0.66666.
Game frames and animation frames may not synch, so you may see frame 29.5 followed by frame 30.7. So you have to check for "did I just now pass time 0.66?" or "am I past 0.66 and haven't thrown yet?"
$$anonymous$$rSteve the animation is being done in $$anonymous$$aya.
Owen Reynolds, I've noticed an animationCurve also has its own time measure 0.0 to 1.0. How would I go about querying those values so I can use them as a condition?
Is there no way to access a key directly? GetComponent().GetAnimationCurveFloat ot something along those lines must exist, I just can't find it.
Your answer
Follow this Question
Related Questions
What is the length of the Keyframe tangent? 0 Answers
How AnimationCurve.MoveKey works? 1 Answer
How do I scale an animation curve by time and value while retaining my tangent values? 0 Answers
How can I give variation to animation curve in Unity? (Raw mocap data) 0 Answers
[Solved]Animation Curve in Code 1 Answer