I’m having some problems with RaycastAll.
I have a situation like this:
O → B → P
O = the enemy.
B = a barrier (e.g. a door) between the enemy and the player.
P = the player.
I’m using the following code attached to the enemy:
RaycastHit[] allHits;
allHits = Physics.RaycastAll(transform.position, transform.forward, coreObject.touchRaycastDistance);
Then basically checking through that for results, getting the distances etc to determine if we’re hitting the door BEFORE the player, etc if the resulting array contains more than one hit.
The problem is, the resulting array ALWAYS only has one hit in it: the player, even though it’s passing through the barrier on the way. I’ve checked the Physics layer matrix thing - everything turned on.
Can anyone think of a reason why it would be hitting the player, but not recognizing that it’s hitting the barrier in between?