how do i correctly use a box collider

For my game, i want to have a fog of war. I want the enemy to be rendered only in the lighted area. So i expanded the box collider of my player(a little cube) and i’ve set up the OnTriggerEnter(hit:Collider) function on my enemy. The problem : unity do not detect anything when player and enemy touch. The OnTriggerEnter funtction is never called :frowning:
pls help

Ps: both player and enemy have rigide bodies and colliders

ok so I dont know how you have it exactly set up however I can guess a certain number of pitfalls that you may have run in to.

-first trigger colliders only detect when the colliding object has both a SOLID collider and a rigidbody

-second in you if statement dont use “==” use other.gameObject.CompareTag (“object”)

-third, never deactivate a gameobject (its almost like destroying it but it still takes up memory) instead de - enable target components that are relavant to your desired effect, in your case disable the mesh renders which you can than renable on trigger enter. DONT disable any colliders

-feel free to use as many colliders as you can, just remember there should be only one solid collider per any interactive gameObject and 99% of the time you dont want to mess with it.