Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

RayPerceptionSensor2D debug gizmos not showing detection

Discussion in 'ML-Agents' started by frieldhelm446, Sep 30, 2020.

  1. frieldhelm446

    frieldhelm446

    Joined:
    Sep 27, 2020
    Posts:
    28
    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.
     

    Attached Files:

  2. henrypeteet

    henrypeteet

    Unity Technologies

    Joined:
    Aug 19, 2020
    Posts:
    37
    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.
     
  3. frieldhelm446

    frieldhelm446

    Joined:
    Sep 27, 2020
    Posts:
    28
    Selecting "Everything" makes the rays invisible, so would seem strange.
     
  4. henrypeteet

    henrypeteet

    Unity Technologies

    Joined:
    Aug 19, 2020
    Posts:
    37
    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?
     
  5. frieldhelm446

    frieldhelm446

    Joined:
    Sep 27, 2020
    Posts:
    28
    Here's what I see using "Everything" as a ray mask


    Everything.PNG


    And here's what I see when "Nothing" is selected.

    Nothing.PNG
     
  6. henrypeteet

    henrypeteet

    Unity Technologies

    Joined:
    Aug 19, 2020
    Posts:
    37
    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:
    1. Move the fish to a layer that doesn't get hit by raycasts.
    2. set the "Queries Start In Colliders" option under edit --> project settings --> physics 2d --> Queries Start In Colliders
    3. Move the sensor in front of the fish
    Please let me know if these don't work for you.
     
    frieldhelm446 likes this.
  7. frieldhelm446

    frieldhelm446

    Joined:
    Sep 27, 2020
    Posts:
    28
    Ah yes, that fixed the issue, thank you!
     
    henrypeteet likes this.