Problem with collision detection

I have two cubes colliding with each other and the following code:

void OnCollisionEnter()
{
        print("");
}

The problem is, it is not printing anything.
In the attached image you can see my cube’s properties. I’ve tried with box colliders & rigid bodies, only colliders, only bodies, but no print so far.
What am I doing wrong?

First of all, without collider, the rigidbody wont work

This is “script” part of the forums, this seems a rather collision kinda thing

Can you post the whole class? Set the collision detection to CCD (continious dynamic)

This is my whole class:

public class SnappingPoint : MonoBehaviour
{
    public GameObject gm;
    public GameObject ckSnap;

    //void OnTriggerEnter()
    void OnCollisionEnter()
    {
        print("");
    }
}

It is attached to both cubes (gameobjects) that you see on the attached image. They have both collider and rigid bodies on each cube

Wait a sec
well, print() is not usable in unity

i guess i can give debug.log a go

[EDIT]

Nope. colision detection problem still here

You can use print just fine in Unity (as long as it’s in a MonoBehaviour class; for some reason it doesn’t do anything otherwise).

–Eric

1 Like

The Rigidbody in the image is kinematic. If the other one is too then it won’t collide (kinematic don’t collide with other kinematic).

See the table here.

1 Like