I don’t know where is the problem, ray just goes through the wall. Layermask is checked correctly and origin is behind the wall. But it still goes through the cube. I want enemy AI not to shoot if there is a wall.
Code:
public virtual bool SeeingAlligned()
{
if (seeingOrigin != null)
{
Ray ray = new Ray(seeingOrigin.position, seeingOrigin.forward*attackDistance);
Debug.DrawRay(seeingOrigin.position, seeingOrigin.forward*attackDistance, Color.blue, 2f);
return Physics.Raycast(ray, out hit, attackDistance, playerLayermask);
}
else
{
Debug.Log("No ray origin for line of sight check");
return false;
}
}