Best practices with colliders/triggers

Hey guys
I’ve been studying Unity for a few months now and one thing that still confuses me a bit is triggers for colliders.

If you have a projectile and an object that it’s suposed to hit, where is best to set the trigger? On the projectile or the object? Is there a “best practice” on this or varies for each case?

Thanks a lot!

1 Like

Over the years, I’ve learned that there are a number of different ways, people would do this, in various game engines. But from what I know, put the trigger sensor on the object, that is going to get hit, by the bullet.

First you should understand the difference between a trigger and a collider. Triggers do not activate physics. Use them for sensors to activate things like opening doors, spawning, starting animations, even changing scenes. Colliders use physics and will affect other objects.

I put my code on the projectiles because I don’t want to add it to 100s of environment objects. Projectile prefabs have the code already added and the number of projectiles are minimal as they are destroyed or pooled.

1 Like

You don’t necessarily even need a trigger for a projectile. You could use regular colliders for both the projectile and the object being hit. That’s what I do unless I want the projectile to be able to pass through the target, or in a case where a raycast makes most sense.