- Home /
change animation name in inspector
how would i go about doing this
var ObjectToAnimate : GameObject; { function Start() ObjectToAnimate.animation.Play("Be able to change this in inspector"); }
iv seen this done not with animation but with changing levels to load but this has me totally stumped
var ObjectToAnimate : GameObject; var animation1 : AnimationClip;
function Start(){ ObjectToAnimate.animation.Play(animation1); }
this is what i come up with but i get this error
Assets/Animate Object.js(5,31): BCE0023: No appropriate version of 'UnityEngine.Animation.Play' for the argument list '(UnityEngine.AnimationClip)' was found.
please select an answer so others can refer to this thread.
Answer by thornekey · Jan 11, 2014 at 06:34 AM
have a variable called 'animaton1' or something then in ur code put
var animation1 : AnimationClip;
ObjectToAnimate.animation.Play(animation1.name); }
?? isnt it like that
EDIT Try var animation1 : Animation; instead
Answer by GameVortex · Jan 11, 2014 at 09:36 AM
Animation.Play requires the name of the animation. So what you do is assign a public animation clip like you have done, but use the name of the animation when playing it.
ObjectToAnimate.animation.Play(animation1.name);
Your answer
![](https://koobas.hobune.stream/wayback/20220613130055im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Animation in Unity 4.3 0 Answers
Animation spins wildly after completed 0 Answers
Animation component in Unity 4.3 doesn't work? 2 Answers
How can I reassign animation curves to play on a child object (instead of through parent)? 1 Answer