# OnTriggerEnter2D or OnCollisionEnter2D not getting called

I checked the other answers for this but mine didn't get fixed Here's the code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DestroyCollectibles : MonoBehaviour
{
private void Start()
{
Debug.Log("Hallo");
}
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("Trigger");
}
private void OnCollisionEnter2D(Collision2D collision)
{
Debug.Log("Collsion");
// if (collision.gameObject.CompareTag("Collectible"))
// {
//     Debug.Log("Apple");
//     Destroy(collision.gameObject);
// }
}
}



And screenshots:

• Missing one rigidbody2d on one object Feb 9, 2021 at 7:53
• Ohhh So i need a rigid body Feb 9, 2021 at 8:04
• OnTriggerEnter is called if your BoxCollider2D (the one which something should enter) is marked as trigger. And as Zibelas said, you are missing a RigidBody2D on one object (the one that is entering). See the note in the docs: docs.unity3d.com/ScriptReference/… or docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html Feb 9, 2021 at 8:12
• That looks like it would make a good answer. Feb 9, 2021 at 9:20

OnTriggerEnter() is called if your BoxCollider2D (the one which something should enter) is marked as trigger. And as Zibelas said, you are missing a RigidBody2D on one object (the one that is entering).