- Home /
Play animation from script in Unity 4.3
I'm trying to play a simple animation from a script in Unity 4.3, but can't get it to work. If it's a legacy animation, Animation.Play("name") works fine as it always has - and that does work if I force all my animations to legacy, but those don't support everything the new system does. A few of my animations change material properties which doesn't seem to work in legacy animations, for instance.
I really don't want to do anything complex, my animations are really simple - but I don't get how to simply start an animation clip in code (C#) - Animation.Play() does not work at all with the new system. For that matter, I can't see an option to disable play automaticall with the new animations either. Can anyone help me out here?
What do you mean by new system? Do yoou mean generic animations? Tried animationPlay("animationName")
?
@ryanas: animationPlay does not seem to exist - animation.Play yields the following error: issingComponentException: There is no 'Animation' attached to the "gameobject" game object, but a script is trying to access it.
Generic animations is probably what I am referring to, yes.
Have you tried manually creating an animation using keyframes and then running the script? I had a similar issue where I imported .m2 files and the animations would only be included when the import is set to "legacy". Try to create a simple transformation, name it and call it in the script. If that works then your models require legacy to use their imported animations.
Your answer
Follow this Question
Related Questions
How do i make an animation play on key press? 3 Answers
animating objects, end position changes 1 Answer
Animation play error. No animation attached. 3 Answers
Play animation when in collider and button pressed 1 Answer
Character won't play animation 8 Answers