public void OnUsedItem(Item item) { // validate if (item.data is UsableItem) { UsableItem itemData = (UsableItem)item.data; itemData.OnUsed(this); } }
// used by local simulation and Rpc, so we might as well put it in a function void OnUsedItem(UsableItem itemData, Vector3 lookAt) { // reset usage time usageEndTime = Time.time + itemData.cooldown; // call OnUsed itemData.OnUsed(this, lookAt); // trigger upperbody usage animation // (trigger works best for usage, especially for repeated usage to) // (only for weapons, not for potions until we can hold potions in hand // later on) if (itemData is WeaponItem) { animator.SetTrigger("UPPERBODY_USED"); } }