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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

RayPerceptionSensorComponent3D detectable objects

Discussion in 'ML-Agents' started by davidhodak225, May 17, 2020.

  1. davidhodak225

    davidhodak225

    Joined:
    Apr 16, 2020
    Posts:
    3
    Hi,
    is there any way to find out which objects are hit by raycasts from agent using RayPerceptionSensorComponent? I want to make environment where 2 agents are playing something like hide and seek, so whenever one agent finds(detects with raycasts) other agent some action should occur.
     
  2. kahabal

    kahabal

    Joined:
    Nov 19, 2018
    Posts:
    16
    hi. dont know if this can help you, but the RayPerceptionSensorComponent allow you to set with TAGS it should consider, you can for sure give agents different tags and let them also play in different Team Id in the behaviour.

    as for my undertanding, the idea behing the rayperception is not a raycast to be used with IF afterwards (you can eventually creare your own raycasts for that), but to give the neural network more inputs to create a stronger environmental reference. it will be your behaviour, training, that will decide that if the raycast is having the "prey" in sight, it will have to react in a certain way, for the "predator" will be mostly the same...

    i hope it will help
     
  3. mbaske

    mbaske

    Joined:
    Dec 31, 2017
    Posts:
    473
    If you just need one agent being able to detect another, you could do a simple line of sight test. Instead of using the RayPerceptionSensorComponent and having multiple observables for a set of ray angles, you could do a single raycast between the two agents. This way, the observation would just be a bool (agent visible or blocked by obstacle) and a vector with the relative direction and normalized distance towards the opponent.