hey, im making a game, i want it so when the player hits a box a plane pears somehow and the player is destroyed so the plane turns into the player, but several problems hapened:
-
when the player colides with the box nothing hapens
-
when the plane is created and the player is destroyed, the plane wont move or use anny physics though it has a rigid body. so here is the code
var player : String; var ObjectToDeploy : GameObject; var bullit : GameObject; var deploy = false;
function Update ()
{if (deploy)
{Instantiate(ObjectToDeploy, Vector3(transform.position.x, transform.position.y + 10, transform.position.z), transform.rotation);
deploy = false; Destroy (gameObject); Destroy (GameObject.Find("Player")); }
}
function OnTriggerEnter (hit : Collider){if (hit.gameObject.tag == player){
deploy = true;
}
}
so plz let me know what can i do or some way to optimize it