UsableItem.UseRate
. UseRate is seconds between uses, so you must decrease UseRate to increase use speed (i.e. to increase by 5%, you would divide by 1.05). ShootableWeapon
, MeleeWeapon
, ThrowableItem
and Explosion
all have the DamageAmount
property that you can directly edit during runtime.shootableWeapon.UseRate /= 1.05f;
// or
shootableWeapon.UseRate = shootableWeapon.UseRate / 1.05f;
using UnityEngine;
using Opsive.UltimateCharacterController.Inventory;
using Opsive.UltimateCharacterController.Items;
using Opsive.UltimateCharacterController.Items.Actions;
public class ItemTest : MonoBehaviour
{
void Start() {
Inventory inventory = GetComponent<Inventory>(); // Get a reference to the character's Inventory
foreach (Item item in inventory.GetAllItems()) { // Loop through all Items in the character's inventory (including items not currently held)
ItemType itemType = (ItemType)item.ItemDefinition; // Get the ItemType of the current Item
if (itemType.ToString() == "AssaultRifle") { // Use the ItemType's name to check if it's the one we want to modify
foreach (ItemAction itemAction in item.ItemActions) { // Loop through all ItemActions of the Item
if (itemAction is ShootableWeapon) { // Specify the ShootableWeapon ItemAction
ShootableWeapon shootableWeapon = (ShootableWeapon)itemAction; // Get the ShootableWeapon component from the ItemAction
shootableWeapon.DamageAmount += 5f; // Increase damage
shootableWeapon.UseRate /= 1.05f; // Increase use rate
}
}
}
}
}
}