- Home /
How do I access locomotion groups via script?
So the documentation for the locomotion system says this:
"In your own scripts the Locomotion System can be blended in and out by using a motion group name as an animation name, for example:
animation.CrossFade("locomotion",0.5f);
This will fade the Locomotion System in over half a second."
This doesn't actually seem to work. When I try to do this exact thing with any of the locomotion groups I have setup Unity reports a null reference error like this:
"The animation state LocomotionAgitated could not be played because it couldn't be found! Please attach an animation clip with the name 'LocomotionAgitated' or call this function only for existing animations."
Any ideas what I'm doing wrong? All I'm currently doing is running a tiny little Javascript file on the character to change this animation on Start to make sure it works before I try anything more complex.
Answer by wilco64256 · Jan 28, 2012 at 05:00 PM
I figured this out - the locomotion system takes some time when the game is initialized to populate the clips that are generated, if you want to change the animation via script this method works, you just need to make sure it's not done right in the Start function.