/// <summary> /// Does setup stuff when the agent is first created /// </summary> private void Awake() { ConfigureLineRenderer(); _head = transform.GetChild(0).gameObject; _eyes = _head.GetComponent <RayPerceptionSensorComponent3D>(); SetUpRayBuffers(); }
// Start is called before the first frame update void Start() { distanceSensorComponent = GetComponent <RayPerceptionSensorComponent3D>(); // sensor = (RayPerceptionSensor)distanceSensorComponent.CreateSensor(); agent = GetComponent <CarAgentDiscrete>(); resetCarStatus(); }
public override void Initialize() { targets = GetComponents <RayPerceptionSensorComponent3D>()[1]; obstacles = GetComponents <RayPerceptionSensorComponent3D>()[0]; movementScript = GetComponent <Movement>(); objectiveScirpt = mainObj.GetComponent <objective>(); Debug.Log(targets.SensorName); Debug.Log(obstacles.SensorName); }
void Awake() { mRigidbody = GetComponent <Rigidbody>(); //tankManager = GetComponent<TankManager>(); rayPerception = GetComponent <RayPerceptionSensorComponent3D>(); mTankFiringSystem = GetComponent <TankFiringSystem>(); mLineRenderer = GetComponent <LineRenderer>(); mLineRenderer.SetWidth(0.2f, 0.2f); mLineRenderer.enabled = false; }
public override void Initialize() { playerType = PlayerType.Prey; enemyType = playerType == PlayerType.Prey ? PlayerType.Predator : PlayerType.Prey; Speed = playerType == PlayerType.Prey ? 7.5f : 8.0f; _rb = GetComponent <Rigidbody>(); _rayPerception = GetComponent <RayPerceptionSensorComponent3D>(); // _rayPerception. // _rayPerception.RaySensor AddToSubject(); }
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) //); }
public override void OnEpisodeBegin() { base.OnEpisodeBegin(); // set the team ID to random so AI's don't avoid shooting each other to avoid a team loss, // not sure if this can be done in the other function or not so I'll put in both places just to be sure GetComponent <BehaviorParameters>().TeamId = (int)Random.Range(0.0f, 100.0f); raySensor = transform.gameObject.GetComponentInChildren <RayPerceptionSensorComponent3D>(); rocket = transform.gameObject.GetComponent <RocketSphereAI>(); rb = transform.gameObject.GetComponent <Rigidbody>(); if (rocket) { lastPoints = rocket.points; } else { lastPoints = 0; } }
// Start is called before the first frame update void Start() { rBody = GetComponent <Rigidbody>(); rayPerception = GetComponent <RayPerceptionSensorComponent3D>(); }