/// <summary> /// Equips the weapon of 'name' by getting it from WeaponManager /// </summary> /// <param name="name">The weapon to equip</param> public void EquipWeapon(string name) { RangedWeapon weapon = WeaponManager.Instance.GetWeapon(name); if (weapon != null) { GameObject currentWeapon = null; if (hand.transform.childCount > 0) { currentWeapon = hand.GetChild(0).gameObject; } if (currentWeapon != null) { currentWeapon.transform.SetParent(WeaponManager.Instance.transform, false); currentWeapon.SetActive(false); } weapon.gameObject.SetActive(true); weapon.transform.SetParent(hand, false); GetComponent <PlayerMovementController>().weapon = weapon.transform; weapon.CallAmmoEvent(); } else { Debug.LogWarning("Weapon: " + name + " can not be found");// } }