void FixedUpdate() { if (agentController.isStriker && Vector3.Distance(ball.position, currentBallRegion) > 0.1f) { Transform nearestTeammateToBall = utils.GetNearestTeammateToPoint(ball.position); foreach (Transform teammate in utils.teammates) { teammate.GetComponent <RCAgent>().isOptimalBallCharger = teammate == nearestTeammateToBall; } isOptimalBallCharger = transform == utils.GetNearestTeammateToPoint(ball.position); currentBallRegion = ball.position; } StreamWriter writer; string path = ""; if ((Vector3.Distance(transform.position, currentTargetPosition) < config.decisionRadius && !isOptimalBallCharger) || (wasOptimalBallCharger && !isOptimalBallCharger)) { readyForDecision = true; wasOptimalBallCharger = false; if (Application.isEditor && GetComponent <Rigidbody>().isKinematic == false) { path = "Assets/Resources/target_data" + (agentController.isLeftSide?"_left":"_right") + ".txt"; writer = new StreamWriter(path, true); writer.WriteLine(string.Format("{0} {1}", currentTargetPosition.x.ToString(), currentTargetPosition.z.ToString())); writer.Close(); stepsSinceTargetWrite = 0; } } if (Application.isEditor && GetComponent <Rigidbody>().isKinematic == false && stepsSincePositionWrite > 3) { path = "Assets/Resources/position_data" + (agentController.isLeftSide?"_left":"_right") + ".txt"; writer = new StreamWriter(path, true); writer.WriteLine(string.Format("{0} {1}", Mathf.Clamp(transform.position.x, -fieldSize.x, fieldSize.x).ToString(), Mathf.Clamp(transform.position.z, -fieldSize.z, fieldSize.z).ToString())); writer.Close(); stepsSincePositionWrite = 0; } if (framesSinceDecision > config.decisionInterval && readyForDecision) { RequestDecision(); framesSinceDecision = 0; readyForDecision = false; } Act(); framesSinceDecision++; stepsSinceStart++; if (isOptimalBallCharger) { wasOptimalBallCharger = true; } }