x


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 ");
  } 
}
more ▼

asked May 12 '11 at 12:35 AM

Ben 39 gravatar image

Ben 39
5 11 12 16

Do you want it to display there forever, or how long?

May 12 '11 at 12:37 AM DaveA

Yes,I want it to display forever.

May 12 '11 at 01:08 AM Ben 39
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first
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);

}
more ▼

answered May 12 '11 at 01:38 AM

Dreamer gravatar image

Dreamer
1.5k 39 49 66

Thank you so much...the script worked perfectly.

May 12 '11 at 09:42 PM Ben 39
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered May 12 '11 at 02:40 AM

lil_billy gravatar image

lil_billy
358 8 12 22

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3698
x1707
x986
x764

asked: May 12 '11 at 12:35 AM

Seen: 1133 times

Last Updated: May 12 '11 at 12:36 AM