Calling multiple targets from one script?

Hi there, I have a script that is trying to call a couple different variables from a couple different game objects. I am using:
var target : myvariable1;
var target : myvariable2;
to recieve the variable.

It works just fine when I have just the first target. The problem is, Unity wont let me have two targets in on script.
Unity just says “Type ‘MyScript’ already has a definition for target”

How do I call different variables from two places in one script?

Thank you

var target1 : myvariable1;
var target2 : myvariable2;

?

Are you looking for a shortcut to access/modify two different instances of two different types? No dice.

Your syntax is not correct.

You want to use:

var variableName : variableType;

not

var variableType : variableName;

So you’d have

var target : GameObject;
var target2 : GameObject;

//and

target.whatever;
target2.whatever;

OR

var targets : GameObject[];

//and

for ( var target : GameObject in targets ) {
 target.whatever;
}

Ahh, I figured it was just something simple.

I thought that you had to name the variable “target” in order to be able to link it to a game object. Unity confused me, because when I named my variable “target” the text went blue in the script editor, where if I named it “target2” it was black. I figured that meant that I could not link “target2” with a game object. As it turns out that is not the case, you can link any variable name with a game object.

Ah, right. That’s because “target” is a variable name of something somewhere. The default “intellisense” Unityscript has is sorely lacking. :<

For prefabs I can only set the target to other objects that are in the project view.