Question on Lootsplosion!

Got a bit of a situation that has been baffling me for a while. I got a pot that I can shoot and destroy no problem, and it instantiates loot fine and I have a box collider set to ‘is trigger’ on the loot objects so the player can pick them up. but i want the loot objects to have physics so i can add an impulse to make it seem like the stuff explodes from the destroyed pot. Adding a rididbody just makes the object fall trough the floor. Removing the ‘it trigger’ solves this but then the player can’t pick them up and just collides with it like a wall.

Imagine the destructible containers from borderlands with how the loot pops out. :stuck_out_tongue:

Thanks for any answer!

What I suggest in this base is to use 2 colliders in the same game object. Unity does not like this a lot, but it should work. So …

(1) Add a normal box collider + rigid body. This box bollider takes the shape of the coin (loot) and it is NOT a trigger. Therefore this collider will stop the coin from falling through the floor.

(2) Then add another collider, say, a sphere collider and set this to “Is Trigger”. This will be used to collect the coin using OnTriggerEnter. I suggest to make the radius of the radius sphere collider larger than the size of the Box Collider so that you can pick the coin well before hitting the Box Collider.

Hope this helps :slight_smile:

You can pick them up with a collider instead of a trigger. Same exact thing, only one has a collision and rigidbody as well.

The same code that goes into the OntriggerEnter would need to go into OncollisionEnter, and probably use a capsule collider as well. Now when you say like wall, do you mean that the objects aren’t moving at all, or the player is kicking them around and not picking them up?

Again, the only real fundamental difference between the trigger and the OnCollisionEnter is that one is solid. What code is in the trigger event that makes it work?