Raycast goes through walls

I’m making an fps game, and I made a level with Probuilder. The enemies shoot a raycast in the player direction, but they hit the player no matter what’s in the way.

9150505--1271956--upload_2023-7-16_13-55-56.png

We can’t see all the code, but layerMask aka playerLayer in your Raycast is likely targeting just the playerLayer, which means the walls are not taken into consideration.

Remove playerLayer from the raycast to target everything (or add walls to the layerMask) so the raycast hits walls too.