function OnTriggerEnter (other : Collider) {
Destroy(gameObject.Ghostmodel);}
Hi I Wrote This Script To Delete A Ghost When I Look Through A Door. To Look Through The Door I Had To Enter A Trigger Zone But It Doesn’t Delete My Ghost.
Help Would Be Appreciated
I would guess you have forgotten to have a look at the documentation.
var ghost :GameObject; // Declare a variable of type game object
function Start(){
ghost = GameObject.Find("Ghost"); // get a reference to the ghost object and assign it to the ghost variable.
//Now using ghost onthis script is using the original ghost object.
}
function OnTriggerEnter (other : Collider) {
//Check who collides using the other variable which is a reference to the object colliding (confusing I know...)
if(other.gameObject.tag == "Player")
// Destroy the ghost object, trying to access the ghost will result in a null reference, it is gone.
Destroy(ghost);
}