/* * void OnTriggerEnter(Collider other) * { * if (heldWeapon != null || !other.gameObject.CompareTag("Weapon")) * { * return; * } * * heldWeapon = other.gameObject; * } * * /* * void OnTriggerExit(Collider other) * { * if (heldWeapon!=null&&other.gameObject.CompareTag("Weapon")&&other.gameObject.Equals(heldWeapon)) * { * heldWeapon = null; * } * }*/ // Update is called once per frame void Update() { var device = SteamVR_Controller.Input((int)trackedObject.index); if (/*body != null && */ heldWeapon != null && device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) { FireArm arm = heldWeapon.GetComponent <FireArm>(); arm.Fire(); device.TriggerHapticPulse(arm.PulseDuration()); } /*else if (body == null && heldWeapon != null && device.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) * { * body = heldWeapon.GetComponent<Rigidbody>(); * body.transform.position = transform.position; * body.useGravity = false; * body.isKinematic = true; * body.transform.SetParent(transform); * joint.connectedBody = body; * body.isKinematic = true; * body.detectCollisions = true; * * } * else if (body != null && heldWeapon != null && device.GetPressUp(SteamVR_Controller.ButtonMask.Grip)) * { * body.velocity = device.velocity; * body.angularVelocity = device.angularVelocity; * body.useGravity = true; * body.isKinematic = false; * body.transform.parent = null; * body = null; * joint.connectedBody = null; * heldWeapon = null; * }*/ }
public void Fire(bool isFirstFrame, Transform camera) { if (isFirstFrame && Time.time - fireArm.lastShotTime >= fireArm.shotDelay + fireArm.shotCooldown) { fireArm.Fire(isFirstFrame, camera); StartCoroutine(StopShooting()); } }
public void Ammu() { if (fireArm != null) { fireArm.Fire(); } else { print("Asetta ei ole asetettu"); } }
void Shoot() { _fireArm.Fire(_bullet); _isReloading = true; Invoke("Reload", 1 / _roundsPerSecond); }