hey, can i use a string variable (whichGemIGot) that is equal to a gameObjects name (Gem - Blue) ??? what i have now gets NullReferenceException
I know this is probably wrong i just cut out the bits that seemed needed to understand my situation. :P
var whichGemIGot : String;
function Update ()
{
if(Input.GetButtonDown("Jump") && isShooter)
{
var child = transform.Find(whichGemIGot);
child.rigidbody.AddRelativeForce(0,-1000,0);
transform.DetachChildren();
isShooter = false;
}
}
function CreateGem ()
{
var whichGem = Random.Range(1,7);
switch(whichGem)
{
case 1:
var Gem11 = Instantiate(Gem1, transform.position, transform.rotation);
Gem11.parent = transform;
whichGemIGot = "Gem - Blue";