void OnCollisionEnter(Collision other) { if (_crashed || _aiCarControl == null || _carController == null) { return; } // Break and disable AI control _crashed = true; _aiCarControl.enabled = false; _carController.Move(0, 0, 0, 0); var survivalTime = _odometer.SurvivalTime; var traveledDistance = _odometer.Distance; var furthestDistance = _odometer.FarthestDistance; // Analyze the results StartCoroutine(AI_Logic.RunEvaluationCoroutine(survivalTime, traveledDistance, furthestDistance, () => { SceneManager.LoadScene(0); // Reset odometer if (_odometer != null) { _odometer.Reset(); } // Enable AI control _aiCarControl.enabled = true; _crashed = false; })); }
private void FixedUpdate() { var sensors = GetSensorValues(); StartCoroutine(AI_Logic.RunAICoroutine(Time.time, Time.deltaTime, sensors, (output) => { _carController.Move(output.Steering, output.Acceleration, output.Footbrake, output.Handbrake); })); }
protected bool rotated = false; //check if rotation was set somewhere else void Start() { /**Gets called by unity when the script is initialized * */ anim = GetComponent <Animator>(); character = gameObject.GetComponent <EnemyCharacter> (); logic = gameObject.GetComponent <AI_Logic> (); agent = gameObject.GetComponent <NavMeshAgent> (); time = 0.0f; shootTimeOut = 0.0f; agent.stoppingDistance = character.stoppingRange; rand = new System.Random(); }
public static void ResetLogic() { _aiLogic = new AI_Logic(); }
static void OnBeforeSceneLoadRuntimeMethod() { AI_Logic.Restart(); }