Hi,
Long time listener, first time caller.
I was following the comment trail on this thread: [With this new code Default Weapon Won’t Add Its Stats Damage! - Unity Courses / Ask - GameDev.tv] (With this new code Default Weapon Won't Add Its Stats Damage!)
As identified by Brian in his solution, changing weapon will de-equip the defaultWeapon (fists), leaving a default square behind in your inventory. I implemented the intended fix for that problem (IItemStore), but it doesn’t seem to prevent the item from clogging up the inventory.
I was wondering whether there’s a better way to do it. I had to add a check for the player to SetupDefaultWeapon(), otherwise enemies will generate a NRE on spawn.
From This:
private Weapon SetupDefaultWeapon()
{
equipment.AddItem(EquipLocation.Weapon, defaultWeapon); //this will trigger UpdateWeapon
}
To This:
private Weapon SetupDefaultWeapon()
{
if (gameObject.tag == "Player")
{
equipment.AddItem(EquipLocation.Weapon, defaultWeapon); //this will trigger UpdateWeapons
}
return AttachWeapon(defaultWeapon);
}
I wasn’t able to just use the single line solution, as it had an error due to not returning.
Thanks!