- Home /
Question by
Altissimus · Aug 23, 2019 at 03:59 PM ·
layermask
LayerMask Issue
Hi,
In the Unity3DCollege FSM tutorial on Youtube, the following line is used to denote the layer mask:
private readonly LayerMask _layerMask = LayerMask.NameToLayer("Walls");
However, this isn't working for me. This is subsequently used in several functions to return a bool, eg:
private bool IsForwardBlocked()
{
Ray ray = new Ray(transform.position, transform.forward);
return Physics.SphereCast(ray, 0.5f, _rayDistance, _layerMask);
}
...and it constantly returns "False", even when it should return "True". There's nothing wrong with the rest of the code because if I change the layermask line to:
int _layerMask = 1 << 8;
(as the layer in question is layer 8), everything performs as it should.
So - any idea please what the problem is with that initial line?
Thanks,
A
Comment