void InteractWithNearestObject() { GameObject nearestObject = Utils.FindNearestObject(gameObject, objectsInRange); if (nearestObject) { PlayerAndNearObjects playerAndList = new PlayerAndNearObjects(gameObject, objectsInRange); nearestObject.SendMessage("InteractWithPlayer", playerAndList); } }
public void InteractWithPlayer(PlayerAndNearObjects playerAndList) { playerAndList.player.GetComponent <Inventory>().AddToInventory(gameObject); playerAndList.objectsInRange.Remove(gameObject); }