Search Unity

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?