- Home /
How to use rigidbody for characters
Hi! I'm creating a 2D game where the character is affected by a lot of external forces. We decided that, since it's a lot of physics, we'd use rigidbody as a basis for the character.
One of the most problematic issues is that a Rigidbody being destroyed, og deactivated, will not cause other colliders to go 'OnTriggerExit'. The same issue goes for 'OnCollisionExit'.
I think I could handle this issue in 'OnDestroy' and 'OnDisable', if all these objects had a custom component, written to handle the issue. Are there any issues with this strategy?
This will be one of the core mechanisms of our game, and the strategy we've been using so far (Coroutines checking a few times per second) feels like it's doing a lot of redundant work.
What exactly are you trying to do, any why do you want to destroy the rigidbody?
Well, the character needs to know when he's falling etc. If whatever he's standing on is deactivated or destroyed, he's not going to receive 'OnCollisionExit'. That's the problem.
With something like that, could it not be solved some other way...like by using gravity? It seems like OnDestroy would be fine for this otherwise. What do you mean by 'if all these objects had a custom component, written to handle the issue'. What issue?
Well, I need OnDestroy to be defined in a particular way, for every object that the character can collide with. That's a much bigger workaround that I had in $$anonymous$$d. All just because OnTriggerExit can not be trusted.