diff --git a/src/cs/MonoGame.Extended.Collisions/CollisionComponent.cs b/src/cs/MonoGame.Extended.Collisions/CollisionComponent.cs
index 349acf8e..e89fa91f 100644
--- a/src/cs/MonoGame.Extended.Collisions/CollisionComponent.cs
+++ b/src/cs/MonoGame.Extended.Collisions/CollisionComponent.cs
@@ -32,9 +32,21 @@ namespace MonoGame.Extended.Collisions
/// Boundary of the collision tree.
public CollisionComponent(RectangleF boundary)
{
- var layer = new Layer(new QuadTreeSpace(boundary));
+ SetDefaultLayer(new Layer(new QuadTreeSpace(boundary)));
+ }
+
+ ///
+ /// The main layer has the name from .
+ /// The main layer collision with itself and all other layers.
+ ///
+ /// Layer to set default
+ public void SetDefaultLayer(Layer layer)
+ {
+ if (_layers.ContainsKey(DEFAULT_LAYER_NAME))
+ Remove(DEFAULT_LAYER_NAME);
Add(DEFAULT_LAYER_NAME, layer);
- AddCollisionBetweenLayer(layer, layer);
+ foreach (var otherLayer in _layers.Values)
+ AddCollisionBetweenLayer(layer, otherLayer);
}
///