public void EquipWeapon(Item itemToEquip) { /* This is where we destroy the item in the players hand to swap/remove weapons. */ if (EquippedWeapon != null) { UnequipWeapon(); } /* Going inside our 'Resources' folder and searching our weapon */ EquippedWeapon = Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug), playerHand.transform.position, playerHand.transform.rotation); /* And we now know that this equipped weapon will contain stas from IWeapon*/ equippedWeapon = EquippedWeapon.GetComponent <IWeapon>(); /* Not all weapons are projectile weapons, hence we need to check the type of weapon is being equipped. */ if (EquippedWeapon.GetComponent <IProjectileWeapon>() != null) { EquippedWeapon.GetComponent <IProjectileWeapon>().ProjectileSpawn = spawnProjectile; } /* Setting Parent to parent it to playersHand (changes Parents) and becomes parented to players hand. */ EquippedWeapon.transform.SetParent(playerHand.transform); equippedWeapon.Stats = itemToEquip.Stats; currentlyEquippedItem = itemToEquip; /* After equipping, we add the stat bonuses. */ characterStats.AddStatsBonus(itemToEquip.Stats); UIEventHandler.ItemEquipped(itemToEquip); UIEventHandler.StatsChanged(); }