private void Initialize() { step = 0; var initialPosition = spawnPosition.localPosition; var targetPosition = target.localPosition; agent = UpwardAgent.Create(initialPosition, targetPosition, moveSpeed); ResetUnityEntities(initialPosition, targetPosition); }
private void Reset(bool changePosition = false) { step = 0; var initialPosition = spawnPosition.localPosition; var initialVelocity = Vector3.zero; var targetPosition = target.localPosition; if (changePosition) { targetPosition.y *= -1f; } agent = UpwardAgent.Update(agent, initialPosition, targetPosition, initialVelocity); ResetUnityEntities(initialPosition, targetPosition); }
public void Step(int maxSteps) { step += 1; var position = unityAgent.body.transform.localPosition; var targetPosition = target.localPosition; var velocity = unityAgent.body.velocity; agent = UpwardAgent.Update(agent, position, targetPosition, velocity); var distanceToTarget = Math.Abs(Vector3.Distance(targetPosition, position)); if (HasReachedTarget(distanceToTarget)) { AgentDone(); } else if (step > maxSteps) { TimeUp(); } else { AgentStep(maxSteps, distanceToTarget); } }