Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Ray Perception Sensor Component 3D distance

Discussion in 'ML-Agents' started by TanksLearning, Apr 14, 2020.

  1. TanksLearning

    TanksLearning

    Joined:
    Apr 2, 2020
    Posts:
    1
    Hello, does the ray perception 3d component get the distance to the object it impacted?.
    I need my agents to get the distance to that object. Is there any way to do that?
    Thanks in advance
     
  2. AndrewGri

    AndrewGri

    Joined:
    Jan 30, 2020
    Posts:
    12
    After several tries to use obsolete ray perception 3d and new ray perception sensor 3d as observations for my agent I created my own logic based on RayCast and happy with that. Imho, using RayCast logic gives better control to a programmer over the training.
    But it does not mean that ray perception components are bad, rather I did not find a way how to use them efficiently.
     
  3. andrewcoh_unity

    andrewcoh_unity

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    162
    RayCasts return a distance normalized between 0 to 1 where 1 corresponds to the max length of the raycast. To get to the distance to an object, you can use a vector observation in the agent script and calculate it manually using the transforms of the two objects.