예제 #1
0
    public override void StartUsing(GameObject usingObject)
    {
        base.StartUsing(usingObject);
        controllerActions = usingObject.GetComponent <VRTK.VRTK_ControllerActions>();



        if (!isUsed)
        {
            bool a = AkSoundEngine.GetIsGameObjectActive(this.gameObject);
            if (!alreadybeenused)
            {
                StartCoroutine(vibrations());
                AkSoundEngine.PostEvent("answering_machine", this.gameObject);
            }
            else
            {
                StartCoroutine(vibrations());
                AkSoundEngine.PostEvent("answering_machine_2", this.gameObject);
            }

            controllerActions.TriggerHapticPulse(0.63f, 0.2f, 0.01f);

            bool b = AkSoundEngine.GetIsGameObjectActive(this.gameObject);
            controllerActions.TriggerHapticPulse(0.63f, 0.2f, 0.01f);
            isUsed          = true;
            alreadybeenused = true;
            this.gameObject.GetComponentInChildren <blinklight>().usage(isUsed);
        }
    }
예제 #2
0
    public IEnumerator vibrations()
    {
        yield return(new WaitForSeconds(0.1f));

        controllerActions.TriggerHapticPulse(1f);
        yield return(new WaitForSeconds(0.4f));

        controllerActions.TriggerHapticPulse(1f);
    }
예제 #3
0
 private void OnCollisionEnter(Collision collision)
 {
     if (controllerActions && IsGrabbed())
     {
         collisionForce = VRTK_DeviceFinder.GetControllerVelocity(controllerActions.gameObject).magnitude *impactMagnifier;
         var hapticStrength = collisionForce / maxCollisionForce;
         controllerActions.TriggerHapticPulse(hapticStrength, 0.5f, 0.01f);
     }
     else
     {
         collisionForce = collision.relativeVelocity.magnitude * impactMagnifier;
     }
 }
예제 #4
0
 public override void StartUsing(GameObject currentUsingObject)
 {
     base.StartUsing(currentUsingObject);
     if (safetySwitch.safetyOff)
     {
         slide.Fire();
         FireBullet();
         controllerActions.TriggerHapticPulse(0.63f, 0.2f, 0.01f);
     }
     else
     {
         controllerActions.TriggerHapticPulse(0.08f, 0.1f, 0.01f);
     }
 }
예제 #5
0
    override protected void OnJointBreak(float breakForce)
    {
        VRTK_ControllerActions controlActions = grabbingObject.GetComponent <VRTK_ControllerActions>();

        controlActions.TriggerHapticPulse((ushort)10000);
        this.Ungrabbed(grabbingObject);
    }
예제 #6
0
 //makes the controller vibrate when it hovers over this button
 void OnTriggerEnter(Collider coll)
 {
     if (coll.name == "Head" || coll.name == "Ring")
     {
         controllerActions = coll.GetComponentInParent <VRTK_ControllerActions>();
         controllerActions.TriggerHapticPulse(1.0f);
     }
 }
예제 #7
0
 private void OnCollisionEnter(Collision collision)
 {
     if (controllerActions && IsGrabbed())
     {
         collisionForce = collision.impulse.magnitude * impactMagnifier;
         controllerActions.TriggerHapticPulse((ushort)collisionForce, 0.5f, 0.01f);
     }
 }
예제 #8
0
 void MenuButtonPressed(object sender, ControllerInteractionEventArgs e)
 {
     if (!mainMenu)
     {
         if (clickable == true)
         {
             clickable = false;
             timeStamp = Time.time;
             controllerActionsL.TriggerHapticPulse(1.0f);
             controllerActionsR.TriggerHapticPulse(1.0f);
             if (menuOpen == false)
             {
                 gameObject.transform.position = viveMenuSpot.transform.position;
                 menuOpen = true;
             }
             else
             {
                 gameObject.transform.position = new Vector3(0, -200, 0);
                 menuOpen = false;
             }
         }
     }
     else
     {
         if (clickable == true)
         {
             clickable = false;
             timeStamp = Time.time;
             controllerActionsL.TriggerHapticPulse(1.0f);
             controllerActionsR.TriggerHapticPulse(1.0f);
             if (menuOpen == false)
             {
                 gameObject.transform.position = viveMenuSpot.transform.position;
                 menuOpen = true;
             }
             else
             {
                 gameObject.transform.position = new Vector3(0, -200, 0);
                 menuOpen = false;
             }
         }
     }
 }
예제 #9
0
    private void PullString()
    {
        currentPull = Mathf.Clamp((Vector3.Distance(holdControl.transform.position, stringControl.transform.position) - pullOffset) * pullMultiplier, 0, maxPullDistance);
        bowAnimation.SetFrame(currentPull);

        if (!currentPull.ToString("F2").Equals(previousPull.ToString("F2")))
        {
            holdActions.TriggerHapticPulse((ushort)bowVibration);
            stringActions.TriggerHapticPulse((ushort)stringVibration);
        }
        previousPull = currentPull;
    }
예제 #10
0
 private void OnCollisionEnter(Collision collision)
 {
     if (controllerActions && controllerEvents && IsGrabbed())
     {
         collisionForce = controllerEvents.GetVelocity().magnitude *impactMagnifier;
         controllerActions.TriggerHapticPulse((ushort)collisionForce, 0.5f, 0.01f);
     }
     else
     {
         collisionForce = collision.relativeVelocity.magnitude * impactMagnifier;
     }
 }
예제 #11
0
 void OnTriggerEnter(Collider coll)
 {
     //check if vive or oculus controller
     if (coll.name == "Head" || coll.name == "Ring")
     {
         //activates aura in update
         currentlySelected = true;
         //vibrate controller
         vrtkController = coll.GetComponentInParent <VRTK_ControllerActions>();
         vrtkController.TriggerHapticPulse(1.0f);
     }
 }
예제 #12
0
 protected override void Update()
 {
     base.Update();
     if (controllerEvents)
     {
         var power = controllerEvents.GetTriggerAxis();
         Spray(power);
         controllerActions.TriggerHapticPulse(Convert.ToUInt16(1000f * power), 0.1f, 0.01f);
     }
     else
     {
         Spray(0f);
     }
 }
예제 #13
0
    public void FireBullet()
    {
        if (flash == null)
        {
            flash = GameObject.Instantiate(muzzleFlash, endOfBarrel.transform.position, endOfBarrel.transform.rotation);
        }
        else
        {
            flash.SetActive(true);
        }

        Magazine mag = transform.Find(magazinePath).GetComponent <Magazine>();

        mag.bulletsInMag--;
        GM.shotsFired++;
        audioSource.PlayOneShot(gunshotClip, 1);
        if (controllerActions)
        {
            controllerActions.TriggerHapticPulse(hapticStrength, hapticDuration, hapticInterval);
        }

        RaycastHit hit;

        if (Physics.Raycast(endOfBarrel.transform.position, endOfBarrel.transform.forward, out hit))
        {
            if (hit.transform.tag.Equals("Enemy"))
            {
                ShootEnemy(hit.transform.gameObject);
            }
            else if (hit.transform.tag.Equals("Civ"))
            {
                ShootCiv(hit.transform.gameObject);
            }
            else
            {
                print("I hit: " + hit.transform.name);
            }


            if (hit.transform.gameObject.GetComponent <ShotSound>())
            {
                hit.transform.gameObject.GetComponent <ShotSound>().Play();
            }
            GameObject decal = Instantiate(decalHitWall, hit.point + (hit.normal * floatInFrontOfWall), Quaternion.LookRotation(hit.normal));
            decal.transform.Rotate(new Vector3(0, 0, UnityEngine.Random.Range(0, 360)));
            decal.transform.localScale = decal.transform.localScale * UnityEngine.Random.Range(.5f, 1);
            decal.transform.SetParent(hit.transform, true);
        }
    }
예제 #14
0
    // Update is called once per frame
    void Update()
    {
        float   tipHeight = transform.Find("Tip").transform.localScale.y;
        Vector3 tip       = transform.Find("Tip/TouchPoint").transform.position;

        Debug.Log(tip);

        if (lastTouch)
        {
            tipHeight *= 1.1f;
        }

        // Check for a Raycast from the tip of the pen
        if (Physics.Raycast(tip, transform.up, out touch, tipHeight))
        {
            if (!(touch.collider.tag == "Whiteboard"))
            {
                return;
            }
            this.whiteboard = touch.collider.GetComponent <Whiteboard>();

            // Give haptic feedback when touching the whiteboard
            controllerActions.TriggerHapticPulse(0.05f);

            // Set whiteboard parameters
            whiteboard.SetColor(Color.blue);
            whiteboard.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y);
            whiteboard.ToggleTouch(true);

            // If we started touching, get the current angle of the pen
            if (lastTouch == false)
            {
                lastTouch = true;
                lastAngle = transform.rotation;
            }
        }
        else
        {
            whiteboard.ToggleTouch(false);
            lastTouch = false;
        }

        // Lock the rotation of the pen if "touching"
        if (lastTouch)
        {
            transform.rotation = lastAngle;
        }
    }
예제 #15
0
 void OnTriggerStay(Collider other)
 {
     if (other.gameObject.GetComponent <VRTK_InteractableObject>().IsGrabbed())
     {
         if (mWasTriggerEnteredSkipped)
         {
             OnTriggerEnter(other);
         }
         VRTK_InteractableObject heldInteractableObject = other.gameObject.GetComponent <VRTK_InteractableObject>();
         GameObject heldControllerGameObject            = heldInteractableObject.GetGrabbingObject();
         if (heldControllerGameObject != null)
         {
             VRTK_ControllerActions heldControllerActions = heldControllerGameObject.GetComponent <VRTK_ControllerActions>();
             heldControllerActions.TriggerHapticPulse(bagHapticVibration);
         }
     }
 }
예제 #16
0
    // Update is called once per frame
    void Update()
    {
        float   tipHeight = transform.Find("Tip").transform.localScale.y;
        Vector3 tip       = transform.Find("Tip").transform.position;

        if (lastTouch)
        {
            tipHeight *= 1.1f;
        }

        if (Physics.Raycast(tip, transform.up, out touch, tipHeight))
        {
            if (!(touch.collider.tag == "Whiteboard"))
            {
                return;
            }

            this.WB = touch.collider.GetComponent <WhiteboardScript>();
            controllerActions.TriggerHapticPulse(0.05f);

            this.WB.SetColor(Color.blue);
            this.WB.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y);
            this.WB.ToggleTouch(true);

            if (!lastTouch)
            {
                lastTouch = true;

                lastAngle = transform.rotation;
            }
        }
        else
        {
            this.WB.ToggleTouch(false);
            lastTouch = false;
        }

        if (lastTouch)
        {
            transform.rotation = lastAngle;
        }
    }
예제 #17
0
 void OnTriggerEnter(Collider coll)
 {
     controllerActions = coll.GetComponentInParent <VRTK_ControllerActions> ();
     controllerActions.TriggerHapticPulse(1.0f);
     if (restartButton == true)
     {
         var menu = GameObject.Find("menu").GetComponent <Menu> ();
         menu.Restart();
     }
     if (waveStartButton == true)
     {
         if (waveStats.gameStarted == false)
         {
             waveStats.gameStarted = true;
         }
         else
         {
             waveStats.NextWave();
         }
     }
 }
    public void AddCalibrationVector(VRTK_ControllerActions controllerActions)
    {
        controllerActions.TriggerHapticPulse(3999);

        Transform appButton      = controllerActions.gameObject.transform.FindChild("Model/button/attach");
        Transform sysButton      = controllerActions.gameObject.transform.FindChild("Model/sys_button/attach");
        Transform controllerBase = controllerActions.gameObject.transform.FindChild("Model/base/attach");

        Vector3 direction = sysButton.position - appButton.position;

        appButtonPoints[numberOfCalibrationVectors]      = appButton.position;
        directions[numberOfCalibrationVectors]           = direction;
        controllerBasePoints[numberOfCalibrationVectors] = controllerBase.position;

        if (numberOfCalibrationVectors < maxCalibrationVectors - 1)
        {
            numberOfCalibrationVectors++;
            Calibrate();
        }
        else
        {
            //CancelInvoke("addCalibrationVector");
        }
    }
예제 #19
0
 void HapticPulse(float collisionForce)
 {
     controller_actions.TriggerHapticPulse((ushort)collisionForce, 0.5f, 0.01f);
 }
 public void VibrateController(ushort rumbleAmount, float duration)
 {
     controllerActions.TriggerHapticPulse(rumbleAmount, duration, 0.01f);
 }
 void OnTriggerEnter(Collider coll)
 {
     controllerActions = coll.GetComponentInParent <VRTK_ControllerActions> ();
     controllerActions.TriggerHapticPulse(1.0f);
     StartWave();
 }
예제 #22
0
 /// <summary>
 /// 手柄震动
 /// </summary>
 protected void Pulse()
 {
     controllerAction.TriggerHapticPulse(strength, duration, interval);
 }
 private IEnumerator ControllersHaptic(float strength, float duration)
 {
     leftControllerActions.TriggerHapticPulse(strength, duration, 0.05f);
     rightControllerActions.TriggerHapticPulse(strength, duration, 0.05f);
     yield return(new WaitForSeconds(duration));
 }