I want to create a scenario in which an agent is able to observe what another agent it observing through their RayPerceptionSensor. Is this possible? and if so what is the best way to do it?
you could try something like that (not at home, writing pseudocode) on agent 1
public GameObject agent2; //refer to agent2 in the inspector
RayPerceptioSensor3d agent2Vision = agent2.GetComponent();
from there you can work on adding it to CollectObservation() but you don’t want to call the Perceive() method of the sensor, because that way you will manually add an observation to the training.
How to get access to the sensor outputs, generated by the decisionRequester, it’s an issue i still have to solve.
I was thinking of doing something like this. Or another more expensive way where I would create new RayPerceptionSensors for agent1 which mirrored the movements of agent2’s sensor
well you still have to reference to the second agent, but you will avoid the aforementioned problem.
just create an empty obj “farSensor” put it inside the agent1 (hierarchy), and attach a RaySensor3d to it.
during the update:
farSensor.transform.position = agent2.transform.position;
that way the sensor is still part of the agent1 observation, and you’ll avoid lots of troubles.
remember to flag “use child sensor” in the behavior tab