How to get "OnCollisionEnter" to work?

Hi there, I have a basic scene with a floor and two objects. Both have rigidBody attached:

In my script, attached to the red cube, I am checking for collisions against the black rectangle.

public class PlayerMovement : MonoBehaviour
{
    [SerializeField] private Rigidbody rb;


    void FixedUpdate()
    {
        rb.AddForce(0, 0, 500 * Time.deltaTime);
    }

    private void OnCollisonEnter(Collision collision) {
        Debug.Log("collision detected");
        if (collision.gameObject.tag == "Obstacle") {
            Debug.Log("Obstacle hit");
        }
    }
}

Despite stripping the scene down to just the basics you see here, neither the “collision detected” debug log nor the “Obstacle hit” debug log ever gets triggered. If I change to “OnTriggerEnter” and change the rigidBody on the blackbox to “is Trigger”, the debug work. But I want to use OnCollisionEnter. What am I doing wrong that no collision is ever detected? Thank you.

FIrst thing I noticed was that you were multiplying the force by Time.DeltaTime. You shouldn’t be doing this. You only need Time.DeltaTime when you are working with linear or angular distances. You want to add the entirety of the force in this frame, not some fraction of it. Same with rb.Velocity. You want to set the entire amount in the calling frame.

So, are you sure that the cube is actually hitting the obstacle? Your collision code is fine and, assuming that the obstacle has a Collider on it, there’s no reason why it shouldn’t work, providing the cube gets that far.