- Home /
Question by
bradm24 · Jun 08, 2015 at 10:51 AM ·
scripting problem
Destroy Game object when leaves camera view
Hi. i am using a csharp script for unity 4.5 and for a bullet game object. When the character ship shoots the bullet i need it to destroy when it leaves the camera view
i am not that good at scripting or understanding it well and my teachers hint was trigger volumns or when it becomes invisible so how do i make the gameobject destroy once it has fired and then become invisible. I have searched this before but there codes dont work for the current unity. So any help asap would be fantastic.
Comment
Answer by spooneystone · Jun 09, 2015 at 06:31 AM
You could put trigger colliders just around your camera view, and then put something like this on the bullet script.
void OnTriggerEnter(Collider other)
{
Destroy(gameObject);
}
Your answer