void EquipWeapon(PlayerWeapon _weapon) { currentWeapon = _weapon; GameObject _weaponInstance = Instantiate(currentWeapon.graphics, weaponHolder.position, weaponHolder.rotation); _weaponInstance.transform.SetParent(weaponHolder); currentGraphics = _weaponInstance.GetComponent <WeaponGraphics>(); if (currentGraphics == null) { Debug.LogError("No WeaponGraphics component on the weapon object: " + _weaponInstance.name); } if (isLocalPlayer) { Utility.SetLayerRecursively(_weaponInstance, LayerMask.NameToLayer(WEAPON_LAYERNAME)); } }
private void Update() { currentWeapon = weaponManager.GetCurrentWeapon(); if (currentWeapon.fireRate <= 0f) { if (Input.GetMouseButtonDown(0)) { Shoot(); } } else { if (Input.GetMouseButtonDown(0)) { InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate); } else if (Input.GetMouseButtonUp(0)) { CancelInvoke("Shoot"); } } }