Sunday, June 26, 2011

creating gui texture when object is destroyed

this is captured from Unity Answers
====================================================================

I am attempting to create a script that will destroy an object that a FPC collides with, then triggering a GUI texture. So far I have found a script to destroy an object based on colliders, is there anything i can add to trigger the GUI?
var other : GameObject;

function OnControllerColliderHit (hit : ControllerColliderHit){

if(hit.gameObject.tag == "Floor") {

Destroy(other);
print("Hey you destroyed me ");
}
}

Answer Algorithm================
======================================================================

var other : GameObject;
var destroyed: boolean;

function OnControllerColliderHit (hit : ControllerColliderHit){

if(hit.gameObject.tag == "Floor") {

Destroy(other);
print("Hey you destroyed me ");
destroyed=true;
}
}


function OnGUI(){
if (destroyed)
GUI.DrawTexture(Rect(10,10,60,60), aTexture);

}

No comments:

Post a Comment