There are answers to similar questions out there, but as a total novice I can't quite put them together.
I want all clones created from a prefab to be put into an array so that said array can be added to another script for the purpose of saving and loading the scene. At the moment, I am unsure how to check if I am adding objects to the array and how the array can be accessed from my SaveLoad script.
#pragma strict
var memory : Rigidbody;
var throwPower : float;
var memoryCounter = 0;
public var memories = new Array ();
//instantiates memory clone on click, renames each clone with identifier and adds object to an Array
function OnClick () {
var clone : Rigidbody;
clone = Instantiate(memory, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection(Vector3.forward * throwPower);
clone.name = "clone" + memoryCounter.ToString();
memoryCounter++;
memories.push (clone);
}
↧