Example #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log("OnTriggerEnter2D " + collision.gameObject.name);
        ITeleportable teleportableObject = collision.GetComponent <ITeleportable>();

        if (teleportableObject != null)
        {
            if (teleportedObjects.Contains(teleportableObject))
            {
                //Debug.Log("This object was teleported here recently");
                return;
            }

            ITeleportable teleportedObject = teleportableObject.TeleportTo(linkedTeleport);
            if (teleportedObject != null)
            {
                linkedTeleport.OnTeleported(teleportedObject);
            }
        }
    }