public override void AgentReset() { //Reset the velocity, position and orientation rigidbody.velocity = Vector3.zero; rigidbody.angularVelocity = Vector3.zero; trail.emitting = false; area.ResetAgentPosition(agent: this, randomize: area.trainingMode); //Update the step timeout if training if (area.trainingMode) { nextStepTimeout = GetStepCount() + stepTimeout; } }
private void FixedUpdate() { if (GameManager.Instance.GameState == GameState.Playing) { //Update the place list every half second if (lastPlaceUpdate + .5f < Time.fixedTime) { lastPlaceUpdate = Time.fixedTime; if (sortedAircraftAgents == null) { //Get a copy of the list of agents for sorting sortedAircraftAgents = new List <AircraftAgent>(aircraftArea.AircraftAgents); } //Recalculate race places sortedAircraftAgents.Sort((a, b) => PlaceCompare(a, b)); for (int i = 0; i < sortedAircraftAgents.Count; i++) { aircraftStatuses[sortedAircraftAgents[i]].place = i + 1; } } //Update agent statuses foreach (AircraftAgent agent in aircraftArea.AircraftAgents) { AircraftStatus status = aircraftStatuses[agent]; //Update Agetn lap if (status.checkpointIndex != agent.NextCheckpointIndex) { status.checkpointIndex = agent.NextCheckpointIndex; status.timeRemaining = checkpointBonusTime; if (status.checkpointIndex == 0) { status.lap++; if (agent == FollowAgent && status.lap > numLaps) { GameManager.Instance.GameState = GameState.GameOver; } } } //Update agent time remaining status.timeRemaining = Mathf.Max(0f, status.timeRemaining - Time.fixedDeltaTime); if (status.timeRemaining == 0f) { aircraftArea.ResetAgentPosition(agent); status.timeRemaining = checkpointBonusTime; } } } }