private void FixedUpdate() { transform.position += (target.position - transform.position).normalized * speed * Time.deltaTime; if (Vector3.Distance(target.position, transform.position) < 1f) { RollerAgent agent = target.GetComponent <RollerAgent>(); agent.SetReward(-1f); agent.Done(); } }
private void CreateAgents() { agent0 = Instantiate(Agent0Prefab, transform).GetComponent <RollerAgent>(); agent0.Area = this; agent0.target = Target.transform; agent1 = Instantiate(Agent1Prefab, transform).GetComponent <RollerAgent>(); agent1.Area = this; agent1.target = Target.transform; agent0.otherAgent = agent1; agent1.otherAgent = agent0; }