# SLayerMask

## Index

### Functions Index

| Function                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p>void <a href="#setlayers"><strong>SetLayers</strong> </a>(params string\[] layerNames)<br>void <a href="#setlayers"><strong>SetLayers</strong> </a>(Table layerNames)</p>   |
| void [**AddLayer** ](#addlayer)(string layerName)                                                                                                                              |
| void [**RemoveLayer** ](#removelayer)(string layerName)                                                                                                                        |
|                                                                                                                                                                                |
| **Static Functions**                                                                                                                                                           |
| <p>static SLayerMask <a href="#new"><strong>New</strong> </a>(Table layerNames)<br>static SLayerMask <a href="#new"><strong>New</strong> </a>(params string\[] layerNames)</p> |
|                                                                                                                                                                                |

### Properties Index

| Property                                    | Description                                    |
| ------------------------------------------- | ---------------------------------------------- |
| bool [**Inverted** ](#new-1)`get` `set`     | Is the mask exclusionary or not.               |
| string\[] [**Layers** ](#layers)`get` `set` | The layer names represented in this layer mask |

## Functions

### SetLayers

void **SetLayers** (params string\[] layerNames)\
void **SetLayers** (Table layerNames)

\_Function that changes an existing layer mask \_

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
-- Let's create a new layer mask to filter out other avatars, then overwrite it to be vehicles instead:
local mask = LayerMask.New({"Avatars"});
mask.SetLayers({"Vehicles"});
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
-- Let's create a new layer mask to filter out other avatars, then overwrite it to be vehicles instead:
local mask = LayerMask.New("Avatars");
mask.SetLayers("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
```

{% endtab %}
{% endtabs %}

### AddLayer

void **AddLayer** (string layerName)

*Add a new layer to an existing layer mask.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
local mask = LayerMask.New("Avatars");
mask.AddLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
local mask = LayerMask.New("Avatars");
mask.AddLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
```

{% endtab %}
{% endtabs %}

### RemoveLayer

void **RemoveLayer** (string layerName)|

*Remove a new layer from an existing layer mask.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
local mask = LayerMask.New("Avatars", "Vehicles", "UI");
mask.RemoveLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
local mask = LayerMask.New("Avatars", "Vehicles", "UI");
mask.RemoveLayer("Vehicles");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
```

{% endtab %}
{% endtabs %}

### New

static SLayerMask **New** (Table layerNames)\
static SLayerMask **New** (params string\[] layerNames)

*Static function that creates a new layer mask*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
local mask = LayerMask.New({"Avatars", "Vehicles"});
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
local mask = LayerMask.New("Avatars");
or
local mask = LayerMask.New("Avatars", "Vehicles", "UI");
local hit = Space.Physics.RaycastSingle(Space.Host.ExecutingObject.WorldPosition, Space.Host.ExecutingObject.Forward, 500.0, mask)
```

{% endtab %}
{% endtabs %}

## Properties

### Inverted

bool **Inverted** `get` `set`

*Is the mask exclusionary or not.*

{% tabs %}
{% tab title="Lua" %}

```lua
local mask = LayerMask.New("Avatars");
-- Now change it to be an exclusionary mask that gets everything EXCEPT Avatars.'

mask.inverted = true;
```

{% endtab %}
{% endtabs %}

### Layers

string\[] **Layers** `get` `set`

*The layer names represented in this layer mask*

{% tabs %}
{% tab title="Lua" %}

```lua
local mask = LayerMask.New("Avatars");
-- Get
local layers = mask.Layers;
-- Set
local layers = {"Vehicles", "UI"};

mask.Layers = layers;
```

{% endtab %}
{% endtabs %}
