(New SLayerMask class for filtering physics hits.) |
(→Properties) |
||
Line 51: | Line 51: | ||
local layers = {"Vehicles", "UI"}; | local layers = {"Vehicles", "UI"}; | ||
mask.Layers = layers; | mask.Layers = layers; | ||
+ | }} | ||
+ | |||
+ | {{ScriptFunction|bool|Inverted|{ get; set; }|Is the mask exclusionary or not.|5= | ||
+ | ''-- Create an inclusionary mask that gets ONLY Avatars.''<br> | ||
+ | local mask = LayerMask.New("Avatars");<br> | ||
+ | ''-- Now change it to be an exclusionary mask that gets everything EXCEPT Avatars.'<br> | ||
+ | mask.inverted = true; | ||
}} | }} | ||
{{Scripting Navbox}} | {{Scripting Navbox}} |
The SLayerMask class provides a wrapper around the Unity LayerMask class for filtering physics hits.
SLayerMask will ignore any layer names that are passed into it that are unknown layers. If your layer mask isn't working as you expect it to, verify that you're using accurate layer names.
You can use the .Layers property to see what layers got accepted by the SLayerMask object.
Static function that creators a new layer mask from a table of layer names.
local mask = LayerMask.New({"Avatars", "Vehicles"});
Static function that creators a new layer mask from one or more string parameters.
local mask = LayerMask.New("Avatars");
or
local mask = LayerMask.New("Avatars", "Vehicles", "UI");
Function that changes an existing layer mask using a table of layer names.
local mask = LayerMask.New({"Avatars"});
mask.SetLayers({"Vehicles"});
Function that changes an existing layer mask using one or more string parameters.
local mask = LayerMask.New("Avatars");
mask.SetLayers("Vehicles");
Add a new layer to an existing layer mask.
local mask = LayerMask.New("Avatars");
mask.AddLayer("Vehicles");
Remove a new layer from an existing layer mask.
local mask = LayerMask.New("Avatars", "Vehicles", "UI");
mask.RemoveLayer("Vehicles");
The layer names represented in this layer mask
-- Get
local layers = mask.Layers;
-- Set
local layers = {"Vehicles", "UI"};
Is the mask exclusionary or not.
local mask = LayerMask.New("Avatars");
-- Now change it to be an exclusionary mask that gets everything EXCEPT Avatars.'
|