Convert String into Variable name

var fHigh1 : Transform;

function OnTriggerEnter ( other : Collider )
{
r = other.transform.position.x;
c = other.transform.position.z;
var name = other.gameObject.name;
Instantiate (name, Vector3(r, 0, c), transform.rotation);
}

This doesn’t work. Gives BCE0023. If I could turn that .name string into the variable name I could save over 80 lines of code. Please help. :slight_smile:

you cannot instanciate a string…
i think you are trying to instanciate a prefeb.
Create a folder called “Resources” put the prefab into and call the function like this:
Instantiate (Resources.Load(name), Vector3(r, 0, c), transform.rotation);