예제 #1
0
    /*
     * 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;
         * }*/
    }
예제 #2
0
 public void Fire(bool isFirstFrame, Transform camera)
 {
     if (isFirstFrame && Time.time - fireArm.lastShotTime >=
         fireArm.shotDelay + fireArm.shotCooldown)
     {
         fireArm.Fire(isFirstFrame, camera);
         StartCoroutine(StopShooting());
     }
 }
예제 #3
0
    public void Ammu()
    {
        if (fireArm != null)
        {
            fireArm.Fire();
        }

        else
        {
            print("Asetta ei ole asetettu");
        }
    }
예제 #4
0
 void Shoot()
 {
     _fireArm.Fire(_bullet);
     _isReloading = true;
     Invoke("Reload", 1 / _roundsPerSecond);
 }