I'm having issues with a Physics.Raycast call in some buggy code that I inherited for a project I'm on, where agents trying to Raycast to a "LatchPoint" layer, which is user layer 8.
Here is the code with the variable names made easier to read:
RaycastHit hitInfo;
int myMask = 1 << 8;
if (Physics.Raycast(sourceTransform.position, (raycastTarget - sourceTransform.position).normalized, out hitInfo, Mathf.Infinity, myMask))
{
storedTransform = hitInfo.transform;
Debug.Log(storedTransform.name);
}
The Debug.Log will print the name of a CharacterController in the "Default" layer, and not get to the CapsuleCollider inside of it on the "LatchPoint" layer. Am I using my mask incorrectly?