Example #1
0
    void Update()// decay hiss so it stops if no button is pressed.
    {
        Debug.Log("gug");
        if (hiss != null)
        {
            hiss.volume *= 0.9f;
        }
        HandDetails cd = dc.receiveHandDetails();

        if (cd != null)
        {
            hand.SetLeapHand(cd.hand);
            hand.UpdateHand();
            Debug.Log("werwr");
            laserBeam.SetActive(beamActive);
            if (beamActive)
            {
                Debug.Log("activeandgesture");
                Finger  f          = hand.GetLeapHand().Fingers[(int)Finger.FingerType.TYPE_INDEX];// index finger.
                Bone    b          = f.Bone(Bone.BoneType.TYPE_DISTAL);
                Vector3 bCenter    = new Vector3(b.Center.x, b.Center.y, b.Center.z);
                Vector3 bDirection = new Vector3(b.Direction.x, b.Direction.y, b.Direction.z);
                laserBeam.transform.position = bCenter;
                laserBeam.transform.forward  = bDirection;       // Raycast, inflate, explode.
                RaycastHit hit;
                if ((Physics.Raycast(bCenter, bDirection, out hit, Mathf.Infinity)) && (hit.collider.gameObject.tag == "Inflatable"))
                {        // Inflate the objectby manipulating scale
                    hit.collider.gameObject.transform.localScale *= 1.0f + (inflationRate * Time.deltaTime);
                    // Play the inflation sound.
                    if (hiss != null)
                    {
                        hiss.volume = 1.0f; if (!hiss.isPlaying)
                        {
                            hiss.Play();
                        }
                    }
                    // Pop the object if it gets too big.
                    if (hit.collider.gameObject.transform.localScale.magnitude > 1.5)
                    {
                        Destroy(hit.collider.gameObject);
                        if (pop != null)
                        {
                            pop.Play();
                        }
                    }
                }
            }
        }
    }