Heya! I’m an animator too so I know how it goes! Unity’s pretty easy to use once you get your head around it though.
That said, you have got a few things wrong with your script, I’ll try walk you through them :
var sweep1 = GameObject;
This is trying to create a variable called sweep1 and assign GameObject to it, which doesn’t make much sense. What you want is
var sweep1 : GameObject;
Which says sweep1 is of type GameObject. Since you define it at the top of your script, you can fill it in via the inspector.
if (Input.GetButtonDown (“1”))
GetButtonDown uses axis you set up in the input manager, so unless you have defined an axis called 1, this won’t work. If you’re expecting it to fire when you press 1 on the keyboard, use GetKeyDown instead. You can read more about inputs in the docs. Also, because you left off the { }'s, this If statement will only apply to the first animation call, the other two would fire constantly.
var sweep1 = animation.Play (“smallsweep”);
var is used to define variables, since you’ve already defined it at the top, you don’t need to do it again. Also, you’re not assigning the animation event, you’re accessing it, so it should look like this
sweep1.animation.Play (“smallsweep”);
Basically you’re saying you want to take sweep1, access it’s animation component, and access the animation’s component Play function to play an animation called “smallsweep”.
So with corrections, you should end up with a script like this :
var sweep1 : GameObject;
var sweep2 : GameObject;
var sweep3 : GameObject;
function Update () {
if (Input.GetKeyDown ("1"))
{
sweep1.animation.Play ("smallsweep");
sweep2.animation.Play ("bigsweep");
sweep3.animation.Play ("giantsweep");
}
}
hope that helps!