public virtual void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("agent")) { TrainingAgent agentScript = collision.gameObject.GetComponent <TrainingAgent>(); // Debug.Break(); if (!isMulti) { agentScript.AgentDeath(reward); } else { agentScript.numberOfGoalsCollected++; if (agentScript.numberOfGoalsCollected == numberOfGoals) { agentScript.AgentDeath(reward); } else { agentScript.AddReward(reward); } gameObject.SetActive(false); Object.Destroy(gameObject); } } }
public virtual void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("agent")) { if (!isMulti) { collision.gameObject.GetComponent <TrainingAgent>().AgentDeath(reward); } else { TrainingAgent agentScript = collision.gameObject.GetComponent <TrainingAgent>(); agentScript.numberOfGoalsCollected++; if (agentScript.numberOfGoalsCollected == numberOfGoals) { agentScript.AgentDeath(reward); } else { agentScript.AddReward(reward); } Object.Destroy(this.gameObject); } } }