Merge colliders2D so it stop collides

How can I merge two colliders so it won’t collide anymore!

First, I must say that scripting and programming is not a problem! If you have a complicated but powerful solution, feel free to share it to me…

So let me explain: Imagine that your 2D player is in a bubble. Once the bubble touches another bubble, the collider (preventing the player to get out) would allow the player to get into the other bubble WITHOUT allowing him to exit the bubbles.

alt text

You said you’d be okay with a complex solution right? :slight_smile:

Here goes:

  1. Make a Bubble component, with a radius property.
  2. Gather all bubbles information in a manager script, as an array for example
  3. When moving your object, create a temporary target position
  4. Check this new position against all bubble’s positions and radii (subtracting the character’s radius)
  5. If it’s within the radius of at list one bubble, assign the new position, otherwise discard it

This will only work with slow moving objects though, as it can’t stop the object half way with a collision.
But it’s a start…

Or, you could do it differently if you want to use physics.

Assign a trigger collider along with the collider.
The collider is disabled until you enter the trigger, which enables that collider and disable all others.