// Callback whenever we enter a "trigger", which is a collder on an object with "isTrigger" checked. private void OnCollisionEnter2D(Collision2D collision) { ConsumableObject consumable = collision.collider.GetComponent <ConsumableObject>(); if (consumable) { consumable.TryBeConsumedBy(this); } }
private void OnTriggerEnter2D(Collider2D collider) { ExitPortal portal = collider.GetComponent <ExitPortal>(); if (portal) { AudioController.instance.PlayPortalSound(); GameController.instance.PortalToScene(portal.sceneToLoad); } BurnableObject burnable = collider.GetComponent <BurnableObject>(); if (burnable) { burnable.TryBeBurnedBy(this); } ConsumableObject consumable = collider.GetComponent <ConsumableObject>(); if (consumable) { consumable.TryBeConsumedBy(this); } }