Beispiel #1
0
    /// <summary>
    /// Handles collisions with asteroids and gold.
    /// </summary>
    /// <param name="collision">The object that hit the trigger</param>
    private void OnTriggerEnter(Collider collision)
    {
        if (collision.gameObject.tag == "Object")
        {
            TakeDamage();
            Destroy(collision.gameObject);
        }

        if (collision.gameObject.tag == "Collectible")
        {
            goldCollected++;
            //Gain large reward for getting gold
            AddReward(2f);
            objectSpawner.MoveGold();
            if (goldCollected >= goldNeeded)
            {
                //Slightly larger award and episode ends when gold needed is reached.
                SetReward(2.5f);
                EndEpisode();
            }
        }
    }