- Home /
Is there a script that will trigger a gui texture when an object is destroyed?
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 by Dreamer · May 12, 2011 at 01:38 AM
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);
}
Answer by lil_billy · May 12, 2011 at 02:40 AM
not that his^ answer isnt awesome but another way you could go about it is instead of destroying the object from the projectile what could do is have the object either look for the project or have a message sent to the object from the projectile and basically there you would toggle your gui and end it with destroy
kind of just depends on what you want mine would probably be more useful if your object has health
Your answer
Follow this Question
Related Questions
If statement not working inside switch statement 1 Answer
OnTriggerEnter is not running! Need help with collision. 2 Answers
Collision With Trigger, Then Add Points To Counter, Then Destroy 1 Answer
how to destroy an object permanently ? 1 Answer
why is OnTriggerEnter Destroy working once then stoping? 0 Answers