I still can’t figure out how to change a variable in a instantiated object. So lets say your moving left and fire a bullet left, if your moving right then fire the bullet right. So inside of my prefab that I instantiate there is a variable for direction = 0. So how would I change this variable to be different for every object I spawn. So if I’m moving left that prefabs direction variable will be 0 and if moving right it will be set to 1 only for that prefabs variable.
The instantiate function includes a rotation parameter so you don’t really need to make your own paramter for that.
See the docs: http://unity3d.com/support/documentation/ScriptReference/Object.Instantiate.html:
static function Instantiate (original : Object, position : Vector3, rotation : Quaternion) : Object
As long as you keep a reference to the created object you can always access the properties.
Check the 2nd example from the above link - it does exactly that:
Rigidbody clone;
clone = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
clone.velocity = transform.TransformDirection(Vector3.forward * 10);