- Home /
OnTriggerEnter2D not working
void OnTriggerEnter2D(Collider2D target){
if (target.gameObject.tag == "Player") {
Destroy (target.gameObject);
}
}
that's my code. I have no kinematics checked on my collectable. target object is a rigid body. But still my gameObject is not destroying. Please help. ,void OnTriggerEnter2D(Collider2D target){ if (target.gameObject.tag == "Player") { Destroy (target.gameObject); }
}
That's my code. IsTrigged is checked and other object is a rigid body still can't destroy it. Please help me.
Answer by Fanttum · Jan 09, 2017 at 10:57 PM
Make sure that the "target" object has 2D physics on it. Meaning a Rigidbody2D or Collider2D. A normal Rigidbody or Collider will not work with OnTriggerEnter2D.
Your answer
Follow this Question
Related Questions
Unity 4.6 UI Touch Detection 1 Answer
[Unity 4.6]Anchor element top side to the bottom side of another element. 0 Answers
U4.6 - Equivalent command to NGUI's UIButton.current to detect which button was clicked 1 Answer
DX11 shader model 5 unavailable 0 Answers
Mesh Collider is Hiding Capsule Collider 0 Answers