Help, Collision Detection

Hello everyone,
I’m new in unity and i’m currently trying to make my first game.
Everything seems to go good until i tried to “register” a collision between 2 objects .

The problem is that the console doesn’t show up the message “Test1” , so it means that the “OnTriggerEnter” isn’t getting executed at all.
This is the collider :

This is the player:

P.S. The player is moved to the collider using wasd.

Edit: The images are too small , here the links:
Script: Unity1 — Postimages
Collider: unity2 — Postimages
Player: Unity3 — Postimages

Hi,
Have you checked that your objects are tagged correctly, as you are also testing if the tag is valid?

Yes, i’ve checked the tag , but the main problem is that the “OnTriggerEnter” Method dosen’t run! I’ve put the line of code “Debug.log(“Test1”);” to test if the function actually get executed but it doesn’t show up anything in the console so i’ve to think that it isn’t working at all.

You are using:
OnTriggerEnter()
but for 2D physics you should use
OnTriggerEnter2D()

Thank you for your answer, i changed what you suggested but still it doesn’t work.
https://postimg.cc/ctmf4djw

I just tried your setup and it works for me.
Did you change layers or tags? Did you change collision matrix?

Anyway, this is script I used:

using UnityEngine;

public class Collision : MonoBehaviour
{
    private void OnTriggerEnter2D(Collider2D collision) {

        Debug.Log("Hit!");
    }
}

And this is full setup for Ground, Box and Spikes. Ground is there so Box does not fall down. Spikes is trigger, so it falls through Box and Ground. Therefore, there are to “Hit!” messages - one for Box and second for Ground:

Try to create small new project and create replica of above.

1 Like

Here it shows that you’ve taken the Rigidbody2D out of the simulation and it even puts a big warning box in the inspector to remind you what you’ve done.

2 Likes

Ty so much, you were right!
And thank to everyone!

1 Like