Esempio n. 1
0
        protected virtual void Engage()
        {
            if (AttachedHand != null)
            {
                AttachedHand.EndInteraction(this);
            }

            CanAttach = false;

            StartCoroutine(HoldPosition(EngageWaitTime));
        }
Esempio n. 2
0
    public override void UseButtonDown()
    {
        base.UseButtonDown();

        GameObject bullet = GameObject.Instantiate(bulletPrefab);

        bullet.transform.position = firePoint.position;
        bullet.transform.rotation = firePoint.rotation;

        bullet.GetComponent <Rigidbody>().AddRelativeForce(bulletForce);

        AttachedHand.TriggerHapticPulse(100, Valve.VR.EVRButtonId.k_EButton_Axis0);
    }
Esempio n. 3
0
        public override void UseButtonDown()
        {
            base.UseButtonDown();

            GameObject bullet = GameObject.Instantiate(BulletPrefab);

            bullet.transform.position = FirePoint.position;
            bullet.transform.forward  = FirePoint.forward;

            bullet.GetComponent <Rigidbody> ().AddRelativeForce(BulletForce);

            AttachedHand.TriggerHapticPulse(500);
        }
Esempio n. 4
0
    public override void UseButtonDown()
    {
        base.UseButtonDown();
        NVRPlayer player = AttachedHand.GetComponentInParent <NVRPlayer> ();

        if (!player.LeftHand || !player.RightHand)
        {
            return;
        }
        NVRInteractable left  = player.LeftHand.CurrentlyInteracting;
        NVRInteractable right = player.RightHand.CurrentlyInteracting;

        if (!left || !right)
        {
            return;
        }
        GameObject leftGame  = left.gameObject;
        GameObject rightGame = right.gameObject;

        if (!leftGame || !rightGame)
        {
            return;
        }

        Constructable leftCons  = leftGame.GetComponent <Constructable> ();
        Constructable rightCons = rightGame.GetComponent <Constructable> ();

        if (leftCons && rightCons &&
            player.LeftHand.UseButtonPressed && player.RightHand.UseButtonPressed)
        {
            Debug.Log("MAKING CONNECTION");
            FixedJoint f = left.gameObject.AddComponent <FixedJoint> ();
            f.breakForce    = breakForce;
            f.connectedBody = right.gameObject.GetComponent <Rigidbody> ();
        }
    }
Esempio n. 5
0
        void OnCollisionEnter(Collision collision)
        {
            if (IsAttached == true)
            {
                foreach (ContactPoint contact in collision.contacts)
                {
                    //haptic rumble
                    ushort uHapticStrength = (ushort)(HapticStrengthMultiplier * lastMagnitude);
                    if (uHapticStrength <= 3000)
                    {
                        AttachedHand.TriggerHapticPulse(uHapticStrength);
                    }
                    else
                    {
                        AttachedHand.LongHapticPulse(1);
                    }

                    //on hit audio picker
                    if (collision.gameObject.name == "Men" || collision.gameObject.name == "KoteR" || collision.gameObject.name == "KoteL")
                    {
                        //Debug.Log("hit " + collision.gameObject.name);
                        if (!hitAudio.isPlaying && lastMagnitude > 0.14)
                        {
                            hitAudio.clip   = hitMen[Random.Range(0, 3)];
                            hitAudio.volume = 1;
                            hitAudio.Play();
                        }
                        else if (!hitAudio.isPlaying && lastMagnitude > 0.08)
                        {
                            hitAudio.clip   = hitMen[Random.Range(4, 7)];
                            hitAudio.volume = (lastMagnitude / 0.14F);
                            hitAudio.Play();
                        }
                        else if (!hitAudio.isPlaying && lastMagnitude > 0.01)
                        {
                            hitAudio.clip   = hitMen[Random.Range(8, 13)];
                            hitAudio.volume = (lastMagnitude / 0.08F);
                            hitAudio.Play();
                        }
                    }
                    else
                    {
                        if (!hitAudio.isPlaying && lastMagnitude > 0.1)
                        {
                            hitAudio.clip   = hitBamboo[Random.Range(0, 6)];
                            hitAudio.volume = 1;
                            hitAudio.Play();
                        }
                        else if (!hitAudio.isPlaying && lastMagnitude > 0.03)
                        {
                            hitAudio.clip   = hitBamboo[Random.Range(7, 9)];
                            hitAudio.volume = (lastMagnitude / 0.1F);
                            hitAudio.Play();
                        }
                        else if (!hitAudio.isPlaying && lastMagnitude > 0.005)
                        {
                            hitAudio.clip   = hitBamboo[Random.Range(10, 12)];
                            hitAudio.volume = (lastMagnitude / 0.03F);
                            hitAudio.Play();
                        }
                        else if (!hitAudio.isPlaying && lastMagnitude > 0.001)
                        {
                            hitAudio.clip   = hitBamboo[13];
                            hitAudio.volume = (lastMagnitude / 0.005F);
                            hitAudio.Play();
                        }
                    }
                }
            }
        }