- Home /
Apply scalar/rotation to animation curves at runtime
Hi Friends,
I'm fairly new to the unity animation engine. I'm using the animation engine to handle some transform movement of some primitive objects (not rigged models) in my game, and am trying to figure out if there is any way I can apply rotation or scaling to the transformation curve values at runtime.
In a very simple example, I have an animation called "step" that moves an object forward by one unit - the curve looks like this:
I'm trying to figure out if there is a convenient way to scale or rotate the transform curves of this animation programatically at run-time, such that I could tweak the animation to move the object backwards instead, or move it forward two instead. I know that in this simplified example, it would be trivial to accomplish the same thing in a script by lerping the object's transform directly in a coroutine, but I'm wanting to know if this approach is feasible as well. I have other animations which are less easily scriptable that I'd like to be able to apply this sort of transform rotation to.
It looks like I could do it if I could get AnimationCurve instances out of the AnimationClip object, but I don't see any property or method in AnimationClip that gets me those animation curves from this doc: https://docs.unity3d.com/ScriptReference/AnimationClip.html. I've seen some other posts mention that dynamically editing curves like this isn't really the intended functionality, so I might be barking up the wrong tree.
It also looks like I might be able to create an AnimationClip from scratch but that also isn't really what I'm wanting to do, as I'm only wanting to modify a small portion of an otherwise complex animation. Does anyone have any thoughts on how this might be accomplished?
Your answer
Follow this Question
Related Questions
Maya export to unity 1 Answer
Animations are not precise 1 Answer
3DSMax animations issue with Unity 0 Answers
How to export with "animations" 0 Answers
3Dmax animation overlap in unity 1 Answer