Exemple #1
0
        private const string Ground = "ground";                        // Tag of ground object.

        /// <summary>
        /// Check for collision with ground, and optionally penalize agent.
        /// </summary>
        void OnCollisionEnter(Collision col)
        {
            if (col.transform.CompareTag(Ground))
            {
                touchingGround = true;
                if (penalizeGroundContact)
                {
                    agent.SetReward(groundContactPenalty);
                }

                if (agentDoneOnGroundContact)
                {
                    agent.Done();
                }
            }
        }
Exemple #2
0
        private const string Obstacle = "obstacle"; // Tag on obstacle
        /// <summary>
        /// Check for collision with a target.
        /// </summary>
        void OnCollisionEnter(Collision col)
        {
            if (col.transform.CompareTag(Obstacle))
            {
                touchingObstacle = true;
                if (penalizeObstacleContact)
                {
                    agent.SetReward(obstacleContactPenalty);
                }

                if (agentDoneOnObstacleContact)
                {
                    agent.Done();
                }
            }
        }