Simple Colliders Question

I’m new to colliders and I’m having trouble getting them to work.

I have an empty game object with a box-collider component. It is parented to a player controller and therefore follows them around.

There are other empty game objects through the scene with box-collider components attached. They are static (not moving) and so a rigid body cannot be added to them.

I want to detect when the player-attached collider and the world colliders collide.

Note: Because I thought my terrain colliders (among others) might get in the way, I thought of suspending these other colliders 100m in the air along with the parented one.

I have tried using onCollisionEnter, but can’t seem to get it to work. I’ve tried different combinations of ‘is trigger’ as well. Please help!

Which one is the trigger? Which one should have the script attached? What should the script look like? Do either of them NEED to be tagged? :frowning:

EDIT: ALSO! Please note I’ve considered using Vector distance, and when the distance between the two objects is less than a certain distance I could trigger the event that way, but there will be thousands of these floating game objects, and vector distance would probably use more processing power than onCollisionEnter + Exit… or would it?

A collision event between two colliders is raised only if the movement was made by the physic engine, like the gravity on a rigidbody. In your case, parenting is moving that empty game object. You need to add the collider on your player.

Or, there is the kinematic notion. Set a rigidbody on that empty game object, child of the player, with a box collider. The rigidboy must be kinematic, without gravity, and frozen on everything. Set the collider as trigger, and you’ll get the OnTriggerXXX events.