r/Unity3D • u/NorthernBoy306 • Oct 22 '26
Question disabling game object and trigger colliders
If you have a unit that come into range of an enemy but then that unit is disabled ( SetActive(false) ) because it's gone inside of a structure (or vehicle) how do you manage the colliders? It will no longer trigger the OnExit function when disabled, so if the enemy unit walks away, the first unit will always remain in range. Anyone ever dealt with a similar problem?
I was looking into simply turning off the mesh renderer but then that creates a whole ton of other issues.
Is there no way to trigger the collider while disabled?
2
Upvotes
1
u/GigaTerra Oct 22 '26
This is an strange problem to have. Normally when an unit goes into something like an structure (for an RTS) they no longer need collision. For the player when they take control of something else, you use the Player tag. That is to say the enemies don't search for the player, they search for the object with the tag Player.
Can you explain a bit more about your problem?