public void GetSensorStuff() { // this is a GetComponent<> in the real code // RayPerceptionSensorComponent attached to child gameobject of agent gameobject // This object is rotated to move sensor around RayPerceptionSensorComponent3D rayComponent = new RayPerceptionSensorComponent3D(); var lengthOfRayOutputs = RayPerceptionSensor .Perceive(rayComponent.GetRayPerceptionInput()) .RayOutputs .Length; var rayDistances = new float[5]; List <float[]> rayBuffers = new List <float[]>() { new float[(2 + 2) * lengthOfRayOutputs], new float[(2 + 2) * lengthOfRayOutputs], new float[(2 + 2) * lengthOfRayOutputs], new float[(2 + 2) * lengthOfRayOutputs], new float[(2 + 2) * lengthOfRayOutputs] }; var rayOutputs = RayPerceptionSensor .Perceive(rayComponent.GetRayPerceptionInput()) .RayOutputs; for (int i = 0; i < 5; i++) { rayOutputs[i].ToFloatArray(2, 0, rayBuffers[i]); } // add just the distances to a new float array which represents all the ray cast distances var distances1 = rayBuffers[0][3]; var distances2 = rayBuffers[1][3]; var distances3 = rayBuffers[2][3]; var distances4 = rayBuffers[3][3]; var distances5 = rayBuffers[4][3]; // I want to convert these distances into Vector3's // assuming this script is attached to gameobject the rays are cast from //RayCastHitLocation( // transform.rotation, // transform.position, // distances1.ReverseNormalise(rayComponent.RayLength) //); }
void Start() { floor10x8 = GameObject.FindGameObjectsWithTag("Floor10x8"); floor8x5 = GameObject.FindGameObjectsWithTag("Floor8x5"); gm = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); fire = GameObject.FindGameObjectWithTag("Fire").GetComponent <Fire>(); previousPos = transform.position; r2 = raySensor.GetRayPerceptionInput(); exits = GameObject.FindGameObjectsWithTag("Exit"); }
/// <summary> /// Sets up arrays which can be used to store vector information from the ray perception sensor /// </summary> private void SetUpRayBuffers() { var lengthOfRayOutPuts = RayPerceptionSensor .Perceive(_eyes.GetRayPerceptionInput()) .RayOutputs .Length; _rayBuffers = new List <float[]>() { new float[(2 + 2) * lengthOfRayOutPuts], new float[(2 + 2) * lengthOfRayOutPuts], new float[(2 + 2) * lengthOfRayOutPuts], new float[(2 + 2) * lengthOfRayOutPuts], new float[(2 + 2) * lengthOfRayOutPuts] }; }
public List<float> GetSensorData() { // check for the sensor data RayPerceptionInput input = distanceSensorComponent.GetRayPerceptionInput(); RayPerceptionOutput output = RayPerceptionSensor.Perceive(input); var list = output.RayOutputs; //RayPerceptionOutput.RayOutput output0 = (RayPerceptionOutput.RayOutput)list.GetValue(0); //print(output0.HitFraction); List<float> hitFractions = new List<float>(); foreach (var listItem in list) { RayPerceptionOutput.RayOutput outputRef = (RayPerceptionOutput.RayOutput)listItem; hitFractions.Add(outputRef.HitFraction); } return hitFractions; }