public void InputUpdate() { if (!debugAiming) { characterStatus.isAiming = Input.GetMouseButton(1); } else { characterStatus.isAiming = isAiming; } if (Input.GetMouseButtonDown(0)) { weapon.Shoot(); } }
// Update is called once per frame void Update() { // Drop weapon when 'T' is pressed if (Input.GetKeyDown(KeyCode.T)) { // Is there a weapon to drop if (weapon != null) { // Remove weapon as a Child of Player weaponAttach.transform.DetachChildren(); // Turn collision back on StartCoroutine(EnableCollisions(1.0f)); // Turn Physics back on weapon.GetComponent <Rigidbody>().isKinematic = false; // Throw Weapon forward weapon.GetComponent <Rigidbody>().AddForce(weapon.transform.forward * weaponDropForce, ForceMode.Impulse); ammoText.text = string.Empty; } } if (Input.GetKeyDown(KeyCode.T)) { // Is there a weapon to drop if (weapon2 != null) { // Remove weapon as a Child of Player weaponAttach2.transform.DetachChildren(); // Turn collision back on StartCoroutine(EnableCollisions(1.0f)); // Turn Physics back on weapon2.GetComponent <Rigidbody>().isKinematic = false; // Throw Weapon forward weapon2.GetComponent <Rigidbody>().AddForce(weapon2.transform.forward * weaponDropForce, ForceMode.Impulse); ammoText.text = string.Empty; } } if (Input.GetKeyDown("1") && !isPrimaryWeapon && weapon != null) { isPrimaryWeapon = true; weapon.SetActive(true); if (weapon2.transform.parent == weaponAttach.transform) { weapon2.SetActive(false); } } else if (Input.GetKeyDown("2") && isPrimaryWeapon && weapon2 != null) { isPrimaryWeapon = false; weapon2.SetActive(true); if (weapon.transform.parent == weaponAttach.transform) { weapon.SetActive(false); } } // Check if the Fire key was pressed if (Input.GetButtonDown("Fire1")) { // Check if there is weapon attached to the Player if (weapon != null) { // Grab WeaponScript to fire projectile WeaponShoot ws = weapon.GetComponent <WeaponShoot>(); if (ws) { ammoText.text = ws.Shoot().ToString(); } } else if (weapon2 != null) { WeaponShoot ws = weapon2.GetComponent <WeaponShoot>(); if (ws) { ammoText.text = ws.Shoot().ToString(); } } } }
public void Attack() { weaponShoot.Shoot(); }