When I pass over a specific gameObject, I want to destroy it which is back.
I ‘trigger’ the object I want disappear and attach the next code to it.
void OnTriggerEnter2D(Collision2D other){
Destroy(gameObject);
}
When I pass over a specific gameObject, I want to destroy it which is back.
I ‘trigger’ the object I want disappear and attach the next code to it.
void OnTriggerEnter2D(Collision2D other){
Destroy(gameObject);
}
You didn’t actually post a question, but let me post a solution anyway. Don’t destroy your object in the trigger - that can have somewhat indeterminate effects on related event calls. Instead, set a flag in the OnTriggerEnter2D, and destroy the object in Update.