# Physics layers - configure what collides with what

**URL:** https://forum.castle-engine.io/t/physics-layers-configure-what-collides-with-what/790
**Category:** News
**Created:** [April 9, 2023, 9:10am UTC](https://forum.castle-engine.io/t/physics-layers-configure-what-collides-with-what/790 "2023-04-09T09:10:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [April 9, 2023, 9:10am UTC](https://forum.castle-engine.io/t/physics-layers-configure-what-collides-with-what/790/1 "2023-04-09T09:10:05Z")

</div>

| [![Physics collisions on platformer](https://forum.castle-engine.io/uploads/default/original/2X/2/24658eab48d19b2dde3ce1882d2555005ac3adf2.png)](https://castle-engine.io/wp/wp-content/uploads/2023/04/physics_platformer_collisions.png "Physics collisions on platformer") |
| [![Physics layer choice in platformer](https://forum.castle-engine.io/uploads/default/original/2X/f/fde3832571412c4e31070f9e0d0eaabebb01e11c.png)](https://castle-engine.io/wp/wp-content/uploads/2023/04/physics_platformer_layer.png "Physics layer choice in platformer") |
| [![Physics collisions](https://forum.castle-engine.io/uploads/default/original/2X/e/eb58294714ced54b2fa7e2cad5f82588609136c2.png)](https://castle-engine.io/wp/wp-content/uploads/2023/04/physics_collisions_editor.png "Physics collisions") |
| [![Physics collisions](https://forum.castle-engine.io/uploads/default/original/2X/9/9c2a997355bd3b2fc29bf9d5d26894276a7073e6.png)](https://castle-engine.io/wp/wp-content/uploads/2023/04/physics_collisions.png "Physics collisions") |
| [![Physics names](https://forum.castle-engine.io/uploads/default/original/2X/f/f7cd9eb28773fbb279a28469bb98f0b0cb1c2cee.png)](https://castle-engine.io/wp/wp-content/uploads/2023/04/physics_layers.png "Physics names") |

I’m proud to announce new feature that enhances our [physics](https://castle-engine.io/physics): _physics layers_.

The idea is really simple: you can spread your objects (`TCastleRigidBody`) into multiple layers, and then configure which layer can collide with which. This way you can make certain things ignore other things. For example, maybe _enemy\_bullets_ should not hit other _enemies_ or maybe _enemies_ should not consider each other when walking (in some 2D games, it is normal that enemies can “pass through” each other).

There are really just 2 things to configure:

1. At each rigid body, set the `TCastleRigidBody.Layer` to indicate the layer on which the body is.

To help with this, you can add names and even longer descriptions to layers. Do this through `Viewport.Items.PhysicsProperties.LayerNames`. In the usual workflow, just click to configure `LayerNames` using “…​” button in the editor. The names and descriptions are only for the developer, to better document the layer meaning.

2. Configure which layer collides with which using the checkboxes at `Viewport.Items.PhysicsProperties.LayerCollisions`. You can set them from code, or click on “…​” from CGE editor to configure them visually.

The simple usage example is in [examples/physics/physics\_3d\_collisions\_layers/](https://github.com/castle-engine/castle-engine/tree/master/examples/physics/physics_3d_collisions_layers). More involved example is in [examples/platformer](https://github.com/castle-engine/castle-engine/tree/master/examples/platformer).

The documentation of this feature is [part of the manual about physics](https://castle-engine.io/physics#_layers).
