Search Unity

Question 2 agents using the same stacked sensor

Discussion in 'ML-Agents' started by NanushTol, Jan 14, 2023.

  1. NanushTol

    NanushTol

    Joined:
    Jan 9, 2018
    Posts:
    131
    I have a setup where my raced AI has 2 agents 1 driver & 1 navigator, I want both of them to use the same raycast stacked sensor to save performance, is there a way to tell the agent which sensors to use instead of using the automatic "use child sensors" ?
     
  2. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    Are you sure that your raycast sensor is a performance bottleneck? I think raycasts are pretty fast. I'd expect the neural network is the main performance bottleneck?
     
    Last edited: Jan 15, 2023
  3. NanushTol

    NanushTol

    Joined:
    Jan 9, 2018
    Posts:
    131
    its my own custom sensor, there are 4 cones casting a total of 42 rays & I have 20+ agents, so it adds up, the sensor main performance hit is mainly producing the cones & rotating them to the agent orientation, so if I can save that it would help a bit, trying to squeez as much as I can
     
  4. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    what if you use GetComponentFromChildren or similar to get hold of the RayPerceptionSensor object, and then call Write, on that, passing in the ObservationWriter? Once you've got hold of this object from one of your own objects, I imagine you should be able to pass the object to other of your objects fairly easily?
     

    Attached Files:

  5. topitsky

    topitsky

    Joined:
    Jan 12, 2016
    Posts:
    100
    You could use Raycast Command, that is very fast.