private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.tag == "LootBox" && lootBoxInRange != null) { Debug.Log("Leaving range of loot box"); lootBoxInRange.CloseBox(); lootBoxInRange = null; } }
private void OnTriggerEnter2D(Collider2D collision) { Debug.Log("Entered a trigger range"); if (collision.gameObject.tag == "LootBox" && (this.gameObject == PlayerManager.LocalPlayerInstance || !PhotonNetwork.IsConnected)) { lootBoxInRange = collision.gameObject.GetComponent <LootBox>(); Debug.LogFormat("setting lootBoxInragne to {0}", lootBoxInRange); } }