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

Question Ray Perception Sensor 3D VS RayCast

Discussion in 'ML-Agents' started by unity_16BEB1D569830D462973, Jul 5, 2023.

  1. unity_16BEB1D569830D462973

    unity_16BEB1D569830D462973

    Joined:
    Mar 15, 2023
    Posts:
    5
    Hello, I am a new user to Unity 3D. Currently I am trying to train ML Agents to detect objects using Ray Perception Sensor 3D, and it is not working. I am thinking of changing the Ray Perception to RayCast, so I was wondering how exactly the Ray Perception Sensor 3D differs from RayCast.
     
  2. smallg2023

    smallg2023

    Joined:
    Sep 2, 2018
    Posts:
    100
    rayperception is a bunch of raycasts, it returns the tag and the distance among a few other things for the agent to automatically observe.
     
  3. ice_creamer

    ice_creamer

    Joined:
    Jul 28, 2022
    Posts:
    33
    Hi, such as Ray 3D, what can it get info? Position? velocity?
     
  4. smallg2023

    smallg2023

    Joined:
    Sep 2, 2018
    Posts:
    100
    the rayoutputs is what it can determine
    https://docs.unity3d.com/Packages/c...ts.Sensors.RayPerceptionOutput.RayOutput.html
    so
    public bool HasHit // if it has hit something
    public float HitFraction // the normalized distance to the hit object.
    public bool HitTaggedObject // if the object is in the list of detectable tags
    public int HitTagIndex // the index of the tag within the list

    it will not directly pick up position as this would be meaningless to the AI, you should use directions and distances to let the AI "see" it's environment.
    velocity is not something it will get by default but it can be learned through changes in distance (might be worth using some stacked observations if velocity is important) or you can supply it via an RB.velocity observation etc.
     
    ice_creamer likes this.
  5. ice_creamer

    ice_creamer

    Joined:
    Jul 28, 2022
    Posts:
    33
    Thanks, it helps me!