I have an object that I want to destroy when a ball enters its collider.
The object is marked as trigger and has a tag named destroy.
The script is attached to the object I want to be destroyed.
The script is not working…what am I missing?
Thanx and Cheers
You said you’re attaching this script to the object you want to destroy, which has a tag of “destroy” - and yet in the OnTriggerEnter you’re checking for “destroy”? - Either do this, and attach it to the object you want to destroy (make sure you have isTrigger checked on the collider of your object in order for OnTriggerEnter to fire):
function OnTriggerEnter(other : Collider)
{
if (other.gameObject.tag == "ball")
Destroy(gameObject);
}
Or attach this to the ball instead:
function OnTriggerEnter(other : Collider)
{
if (other.gameObject.tag == "destroy")
Destroy(other.gameObject);
}
You're welcome! - If my answer solved your problem, please mark it as correct to close the question so that others don't think it's active and we can move on :)
Awesome...learning till I die. Thanx
– PumaManManYou're welcome! - If my answer solved your problem, please mark it as correct to close the question so that others don't think it's active and we can move on :)
– vexeProblem solved!
– PumaManManGreat! - Don't forget to mark the answer as correct. (The little 'correct' mark below the thumbs up/down icons)
– vexeThanks.....
– A-Tunga