Not getting the call to OnTriggerEnter2D

I’m going through the collider part of the course, got the circle working as the video shows. However, when I added the rectangle and set its ‘Is Trigger’ checkbox to checked, I don’t get the call to OnTriggerEnter2D to tell the collision script that it happened.

My code looks like trhis:

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

public class Collision : MonoBehaviour
{
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log("Ouch!");
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Trigger!");
    }
}

These are the Car Object settings:

and these are the Square Object settings:

Did I miss something here? I have the Square object set as a trigger, yet no call to the collision script.

I hate to be such a bother, but I don’t want to leave something in this course not working assuming it will fix itself later.

I’m using Editor Version 2022.3.26f1

Sorry, caught it after I hit the post button. The collider object was the non-2D version. I removed that one and replaced it with Box Collider 2D and set the trigger and it’s working perfectly.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms