RayPerceptionSensor2D debug gizmos not showing detection

Hello, I have an Agent with a RayPerception2d sensor. In the scene view I can see the rays shooting out, however when they hit an object with the tag I specified, it fails to show that it was detected, that is the line stays white (instead of going red). Could something be wrong with my configuration?

I attached the configuration.

6364635--708270--Capture.PNG

Hi, I think your issue is likely the ray layer mask. The items that are checked in the drop down indicate the layers that the ray CAN hit. IIUC specifying “Nothing” means that nothing will ever trigger it. Please let me know if this doesn’t wind up fixing the issue.

Selecting “Everything” makes the rays invisible, so would seem strange.

Hmm, thanks for the followup. You likely want everything except the “Ignore Raycast” layer to be included but it is odd that rays are not showing up when the object containing the gizmo is selected. Can you try setting the layer mask to everything except “Ignore Raycast” and make sure there are no detectable objects close in that may be intercepting the rays early? If this continues can you try making an empty game object with the sensor and see if the rays are still missing?

Here’s what I see using “Everything” as a ray mask

6372294--709383--Everything.PNG

And here’s what I see when “Nothing” is selected.

6372294--709386--Nothing.PNG

It looks like your sensor with everything enabled may be detecting the fish it is inside (indicated by the red cross-hairs). I think you can either:

  • Move the fish to a layer that doesn’t get hit by raycasts.
  • set the “Queries Start In Colliders” option under edit → project settings → physics 2d → Queries Start In Colliders
  • Move the sensor in front of the fish

Please let me know if these don’t work for you.

1 Like

Ah yes, that fixed the issue, thank you!

1 Like