Hello. I am using this script to delete gameobjects in an area.
function OnTriggerEnter (other : Collider) {
Destroy(other.gameObject);
}
How can I delete specific gameobjects and not all of them?
Hello. I am using this script to delete gameobjects in an area.
function OnTriggerEnter (other : Collider) {
Destroy(other.gameObject);
}
How can I delete specific gameobjects and not all of them?
Use tags to identify what object enters the trigger.
if(other.tag == "example") {
Destroy(other,gameObject);
}
I used a tag now. if (other.gameObject.tag == "Player") { function OnTriggerEnter (other : Collider) { Destroy(other.gameObject); } } It gives me errors though. Edit: I tried the code you gave me but I get the error: Unknown identifier 'other'.
– KunkkaHereBecause you are doing it wrong. You have to do the if statement inside OnTriggerEnter.
– PiflikThis is what i have got so far. function OnTriggerEnter(other,Collider) { if (other.gameObject.tag =="player");{ Destroy(other.gameObject); }} I get one error now, unexpected token: , found ';' (right after (other.gameObject)
– KunkkaHere