Ejemplo n.º 1
0
        void OnTriggerExit2D(Collider2D col)
        {
            Behavior.ITargetable targetableObject = col.gameObject.GetComponent <Behavior.ITargetable>();
            Behavior.ITargetable currentTarget    = targetBehavior.getTarget();

            // Clear target if it leaves the radar zone
            if (targetableObject != null && !targetableObject.Equals(null) &&
                currentTarget != null && !currentTarget.Equals(null))
            {
                if (targetableObject.getGameObject().GetInstanceID() == currentTarget.getGameObject().GetInstanceID())
                {
                    targetBehavior.clearTarget();
                }
            }
        }
Ejemplo n.º 2
0
        void OnTriggerEnter2D(Collider2D col)
        {
            Behavior.ITargetable targetableObject = col.gameObject.GetComponent <Behavior.ITargetable>();

            // Set target if it enters the radar zone
            if (targetableObject != null && !targetableObject.Equals(null))
            {
                // Ignore targets that are not `objectToTarget`
                if (targetObjectId != targetableObject.getGameObject().GetInstanceID())
                {
                    return;
                }

                targetBehavior.setTarget(targetableObject);
            }
        }