I have a character that can dynamically change its scale (it is a blob of jello that can split and recombine itself and also shoot and collect bubbles to shrink and grow). If the character stand right next to a collider and then grows, he is able to phase through the object.
Additional colliders don’t solve the problem, they merely force the player to shrink/grow multiple times before he can glitch through a wall.
My character uses a CharacterController for collision and movement (characterController.Move()). Growing is done via transform.localScale
Is there a reliable way to force the player out of a collider, after changing its scale, or away from it before?
Growing rigidbodies tend to “push away” from surfaces as they grow. I’m not saying switch to one, but, for your blob, you may start thinking an RB would work better than a character controller, anyway, so one more reason to switch.
RB’s can still have the “grow into an overlap” problem. But if they grow slowly enough then the physics step will see the small overlap and decide to push them apart. If may not work as well if you are moving quickly and growing. Just in case, I move them “up” the amount they grow, to keep them from growing through the floor.
For the additional wall colliders you tried, could put them hidden just barely inside/behind other colliders, with “push player away” code. The idea is, if the player is touching them, you know it grew through something and you have a problem. Use OnCollisionStay, and a physics-layer mask to only see the player.