I am trying to make a Raycast only collide with objects on the “template” layer, but no matter what I try the ray detects collisions on the default layer too.
void RenderTemplate() //Renders building template
{
int mask = (1 << LayerMask.NameToLayer("template"));
RaycastHit templatehit;
Physics.Raycast(MouseRay, out templatehit, mask);
template.SetActive(true);
template.transform.position = Vector3.ProjectOnPlane(templatehit.point, Vector3.up) - Vector3.up * 1.5f;
}
Why doesn’t this work?