- Home /
Destroy object then remake object
Ello, Im trying to finish off the audio to my game, I have onle last problem where I'm trying to make it so what you walk into an object a sound is triggered then the object disappears so the player doesnt walk into it again. I have that bit. Now I want to make the object reappear after a certain amount of time.
I'm trying to add to this.
var trigger : AudioClip;
function Start () { audio.loop = false; }
function OnTriggerEnter (other : Collider) { if(other.gameObject.name == "MainCharacter"){ audio.PlayOneShot(trigger);
}
} function OnTriggerExit (other : Collider) {
Destroy (gameObject, 10);
}
Thanks
Answer by Toxic Blob · Nov 20, 2010 at 07:01 PM
Rather than destroying it, you could disable the collider so the object can't be collided against (hence, not triggering the sound). You could also then disable the MeshRenderer so that no object is displayed to the player.
Then, after a specified amount of time you could enable both the MeshRenderer and the Collider.
Thanks Iv got that working now with this.
var trigger : AudioClip;
function Start () { audio.loop = false; }
function OnTriggerEnter (other : Collider) { if(other.gameObject.name == "$$anonymous$$ainCharacter"){ audio.PlayOneShot(trigger);
}
} function OnTriggerExit (other : Collider) {
collider.isTrigger = false;
yield WaitForSeconds (5);
collider.isTrigger = true;
}
Im now trying to make the sound come from a child object I'v been shown how to do this before but have gone completely blank, any ideas?
Thanks
Your answer
Follow this Question
Related Questions
Any Idea why my Explosion sound is NOT playing ? 1 Answer
Play Sound on Destroy 1 Answer
PlayOneShot keeps playing for ever (loops) 2 Answers
My soundclip is noisy? 2 Answers
Play Sound on Destroy 1 Answer