Version: Unity 6.6 (6000.6)
LanguageEnglish
  • C#

PhysicsLayers.GetLayerMask

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static PhysicsMask GetLayerMask(params string[] layerNames);

Parameters

Parameter Description
layerNames The layer names (case sensitive) to find a combined physics mask for.

Returns

PhysicsMask The combined physics mask for the layer names that were found. Unity produces a console warning for each layer name that isn't found and leaves it out of the mask, so if no names are found, PhysicsMask.None is returned.

Description

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

Use this method to build the category and contact masks for a ContactFilter so a shape only collides with the layers it needs to. Create the layers in a PhysicsCoreSettings2D asset first. When physics layers are active and more than one layer has the same name, the mask includes every layer with that name.