One script, modify two different objects?

Can I have one script, and have it modify two different game objects? For example, click a button and have it move a sphere and a square to a desired position? If so, how?

Thanks!

You might be able to do it that way if you have a reference to another game object you should be able to script it. A reference could be searched for or set as a public variable through the script’s properties panel. That way you can control any game object from any script dynamically or otherwise as the script has a reference to the object it will be easy to update from a local set variable holding the reference to the target game object.

Just select the best option for your layout.

There’s no easier way, like GameObjectName.transform.position = Vector3(5, 4.5, 5); ? Where you can take a game object and name it for scripting purposes?

Yes, you can search for the game object you want to manipulate to get a reference. Without a reference to the game object there is no way for the script to access the game object.

Game object names are not global references so you have to do a search (by name probably) to get a reference to the game object.
Then you can set all the transforms you want while that object is instanced.

There are overheads with searches so the first option would be to preset the game object as a public variable of your script through the script’s properties panel if that is practicle.

Go in this direction:
http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

Good Luck