Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Gizmos of Ray Perception Sensor

Discussion in 'ML-Agents' started by whbhb, Mar 5, 2020.

  1. whbhb

    whbhb

    Joined:
    Feb 1, 2020
    Posts:
    4
  2. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
    What is the Behavior Type of the Agent's Behavior Parameters? If it's set to "Heuristic Only", the gizmos won't draw in version 0.14.1 (this will be fixed in the next release).
     
  3. whbhb

    whbhb

    Joined:
    Feb 1, 2020
    Posts:
    4
    I used "Heuristic Only" but when I changed Behavior Type to "default", there was still no gizmos. I am using version 0.13.
    Do I need to write some code like Debug.Draw to make it appear?
     
  4. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
    You'll still need to be in Play mode to see the gizmos.
     
  5. whbhb

    whbhb

    Joined:
    Feb 1, 2020
    Posts:
    4
    I might find the problem. OnDrawGizmos() of RayPerceptionSensorComponentBase.cs file does not work in my case.
    Code (CSharp):
    1. if (m_RaySensor?.debugDisplayInfo?.rayInfos == null)
    2. {
    3.      return;
    4. }
    My code directly returns and doesn't run the drawing part below. If I remove or comment these lines, gizmos can show in play mode.
    Any idea of what causing this premature return? Thanks.
     
  6. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
    Which version of the code are you looking at? In the 0.14.1 release, that line is used to guard against null references - if the method was returning on that line, then either debugDisplayInfo or rayInfos was null, so this part of the code

    https://github.com/Unity-Technologi...RayPerceptionSensorComponentBase.cs#L109-L115

    would definitely crash.

    Anyway, if you're happy with your workaround for now, that's fine; this will all be improved in the next release.
     
  7. whbhb

    whbhb

    Joined:
    Feb 1, 2020
    Posts:
    4
    I am using 0.14.0. I am new to unity. Is there any way to set references so that they are not null?