How to make a certain function if an object collides with another object? Been searching it up for 2 months.

idk what is wrong with the code:

void OnCollisionEnter(Collision col)
{

        Debug.Log("Collided");

}

it doesn’t work for some reason. And I also need to check “if (col.collider.gameObject.tag == “red”)”, but I can’t as it doesn’t even send the message to the console, it doesn’t work.

Some details:

One of my objects is set to dynamic, but the other one - to kinematic.
I’m using Unity UI and a canvas.
That script is on the dynamic object.

I’ve been searching for solutions, reading a lot of posts for a little over 2 months now. Even took a break for 1 month cause this is just cancer. Should I just suicide at this point lol

both objects must have rigid bodies attached, and at least one must be non kinematic.
also try putting your script on both objects… see if only one is getting the message.
Also try adding OnCollisionStay() with a log message in case they are already colliding.

See unity docs

also try this tutorial