# GetLayerMask(params string[])

> Get a PhysicsMask for the specified layer name(s).

## Definition

* **Type:** Method
* **Namespace:** [Unity.U2D.Physics](/engine/6000.7/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule

## GetLayerMask(string\[])

```csharp
public static PhysicsMask GetLayerMask(params string[] layerNames)
```

### Parameters

**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): The layer names (case sensitive) to find a combined physics mask for.

### Returns

| Type                                                                            | Description                                                                                                                                                                                                                               |
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [PhysicsMask](/engine/6000.7/script-reference/unity/u2d/physics/physicsmask.md) | The combined physics mask associated with the specified layer names. If a layer name isn't found, Unity produces a console warning and returns [PhysicsMask.None](/engine/6000.7/script-reference/unity/u2d/physics/physicsmask/none.md). |

### Remarks

Use this method to build the category and contact masks for a [PhysicsShape.ContactFilter](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape/contactfilter.md) so a shape only collides with the layers it needs to. Create the layers in a [PhysicsCoreSettings2D](/engine/6000.7/script-reference/unity/u2d/physics/physicscoresettings2d.md) asset first.

### Examples

```csharp
// Get a physics mask for a single layer, and another for a group of layers
// that the object should collide with.
using UnityEngine;
using Unity.U2D.Physics;

public class GetLayerMaskExample : MonoBehaviour
{
    void Start()
    {
        PhysicsMask objectLayer = PhysicsLayers.GetLayerMask("Car");
        PhysicsMask contactLayer = PhysicsLayers.GetLayerMask("Walls");
    }
}
```
