- Home /
How to modify animation curve in run time?
I have a model. When he play "shooting", I want to modify animation keyframe to make he's arm can follow target.How do I do?
Could you please elaberate more one which target you are want the arm to follow, where is the target, what is the arms purpose, how fast is this all meant to happen. If you have any current code if you could post it that would be great, Thanks in advance :)
The model is enemy. The target is player.When he attack player, he will raised his gun and shooting. I want to control his arm rotation to aim player. I try to rotate arm's bone, but it is difficult. The animation hinder me to rotate it. So I think maybe I can modify the shooting animation final keyframe in run time. That will be easy more, but I don't know it can do or not. $$anonymous$$y English is not good, sorry.
It's fine, as long as you can type in a language i understand then theres no need for appologies. You can try making the enemy constantly looking at the player, which can be found in this youtube series. http://www.youtube.com/watch?v=jN3XCOl$$anonymous$$ZsU Hope this helped :)
Guys, please post answers as answers, not as comments.
Answer by Paulius-Liekis · Apr 17, 2012 at 10:22 AM
You don't need to modify animation curve for that. Simply change tranform position/rotation values in LateUpdate call, this will override your main animation.
http://unity3d.com/support/resources/example-projects/3rdpersonshooter is a good resource to learn more about animation control.
and nobody answered the question. How to modify animation curve in run time?
You can use AnimationClip.SetCurve and http://docs.unity3d.com/Documentation/ScriptReference/AnimationCurve-keys.html to modify animations and curves at runtime.
Answer by Varaughe · Oct 12, 2013 at 08:11 AM
I do think, you'll need to have two animations very similar,and try to blend between them at runtime so that your character to follow your target... otherwise to change at runtime an animation clip ,seems rather impossible ...