- Home /
Question by
infamouslyuseless · Dec 18, 2013 at 10:43 PM ·
animationerroranimatorsemicolon
';' expected insert a semicolon at the end, i've put a semicolon
So apparently there's something wrong with this line in my script:
Animator animator = GetComponent(Animator);
I get this error. "';' expected. Insert a semicolon at the end."
How do I fix this please?!
Comment
Answer by Bunny83 · Dec 18, 2013 at 10:46 PM
Your line of code doesn't make sense. The first part looks like C# the second part is UnityScript. So you should either do:
// C#
Animator animator = GetComponent<Animator>();
// or
Animator animator = (Animator)GetComponent(typeof(Animator));
Or if you use UnityScript
// UnityScript
var animator = GetComponent(Animator);
// or
var animator = GetComponent.<Animator>();
I recommend the first if you're using C#, it's neater and should be slightly faster. Generics are preferable to a cast if you can use them.
aah, ok. I got given that line of code, I understand now thanks :)