- Home /
Destroy a Game object on collision and add it to my Gui???
So I need a script for my game i've been working on, progress has been pretty good. To be honest its one of my most worked on projects yet. Its just i've run into a couple problems before and this one is causing me to draw a blank any help?????.
The object I want to pick up is called "rupee animated" and the name of my gui is called "rupee text beta".
I just want a script where if you walk into a game object it destroys itself (disappears) plays a sound and then adds itself to the gui. any help????????
here is something I have so far
function OnCollisionEnter(collision : Collision) { if (collision.gameObject.name == "rupee animated"){ // if the hit object's name is rupee animated... Destroy(gameObject); // destroy it } }
var Get_Rupee : AudioClip; // set this to your sound in the inspector
function OnCollisionEnter (collision : Collision) { // next line requires an AudioSource component on this gameobject audio.PlayOneShot(Get_Rupee);
these links should help http://www.youtube.com/watch?v=c$$anonymous$$JiSsqZCJ$$anonymous$$&list=PL27B696FB515608D2 http://www.youtube.com/watch?v=hbjB80-$$anonymous$$c7E&list=PL27B696FB515608D2 http://www.youtube.com/watch?v=bt$$anonymous$$dGy3hBw4&list=PL27B696FB515608D2 http://www.youtube.com/watch?v=I6fkQQSWwNs&list=PL27B696FB515608D2
Answer by digiben · Feb 17, 2013 at 06:58 AM
What's the problem so far, is the item being destroyed at least? What's with the two OnCollisionEnter scripts.. is this in different files? What GUI are you using and do you have the general logic on how to add something in your GUI setup or is that your confusion? Is this OnGUI or NGUI or something else?