public override void AgentAction(float[] vectorAction) { Vector3 controlSingnal = Vector3.zero; controlSingnal.x = vectorAction[0]; controlSingnal.z = vectorAction[1]; rigidbody.AddForce(controlSingnal * speed); float distanceToTarget = Vector3.Distance(transform.position, target.position); if (distanceToTarget < 1.42f) { SetReward(1.0f); Done(); otherAgent.SetReward(-1.0f); otherAgent.Done(); } if (transform.position.y < 0) { SetReward(-1f); Done(); otherAgent.SetReward(1.0f); otherAgent.Done(); } }
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(); } }