how to collide while having a trigger?

I have a script that uses OnTriggerEnter to detect a collision. The problem is the thing it collides with goes right through it. Is there a way to use OnTriggerEnter and not have the thing it collided with go through it?

Use OnCollisionEnter in the script and disable the ‘isTrigger’ checkbox so that it becomes a normal collider. When the ‘thing’ collides, the script will do its job.

PS : Just keep in mind that the OnTriggerEnter function returns a Collider variable, where as the OnCollisionEnter returns Collision variable, just something that people forget sometimes. Look it up in the scripting manual.

The trigger functionality is simply for the purpose of being notified when a rigidbody has entered a particular area covered by a collider, meaning there won’t be collisions with the collider.

What you want to do is disable the isTrigger checkbox on the collider and define the OnCollisionEnter method in your script. Like this:

Then, you will have your collision handled while being able to script something once the rigidbody has entered the collider.

You need to make sure that your Player/Object has a rigidbody and the object it is colliding has a collider component. Also, make sure the script with the OnCollisionEnter is on the object with the collider.