Hi.
I use three Ray Perception Sensor Components for measuring distances from the agent to some objects, and I’d like to get all values (HasHit, HitTaggedObject, HitTagIndex and HitFraction) from all components.
My code is below.
public override void OnActionReceived(float[] vectorAction)
...
var r1 = this.GetComponent<RayPerceptionSensorComponent3D>();
var r2 = r1.GetRayPerceptionInput();
var r3 = RayPerceptionSensor.Perceive(r2);
{
foreach(RayPerceptionOutput.RayOutput rayOutput in r3.RayOutputs)
{
Debug.Log(rayOutput.HasHit+" "+rayOutput.HitTaggedObject+" "+rayOutput.HitTagIndex+" "+rayOutput.HitFraction);
}
}
Sensor Name:
- RayPerceptionSensor
- RayPerceptionSensor1
- RayPerceptionSensor2
I wrote this code to get values of three Ray Perception Sensor 3D components, but I could get only values of RayPerceptionSensor.
How should I write a code to get values of RayPerceptionSensor1 and RayPerceptionSensor2? If anyone know, please let me show methods or ideas.
Thanks ![]()