//------------------------
    // Init
    //------------------------
    void Start()
    {
        if (this.gameObject.GetComponent <SVAbstractGripIndicator>())
        {
            gripIndicatorComponent = this.gameObject.GetComponent <SVAbstractGripIndicator>();
        }

        this.input     = this.gameObject.GetComponent <SVControllerInput>();
        this.rb        = this.GetComponent <Rigidbody>();
        this.colliders = (Collider[])SVUtilities.AllComponentsOfType <Collider>(gameObject);

        if (SVGrabbable.leftHandCollider == null)
        {
            GameObject obj = new GameObject("Left Hand Collider");
            obj.AddComponent <SVColliderUpdater>().isLeft = true;
            SVGrabbable.leftHandCollider = obj;
        }

        if (SVGrabbable.rightHandCollider == null)
        {
            GameObject obj = new GameObject("Right Hand Collider");
            obj.AddComponent <SVColliderUpdater>().isLeft = false;
            SVGrabbable.rightHandCollider = obj;
        }
    }
示例#2
0
// Update is called once per frame
    void Update()
    {
        audioSource        = SVUtilities.SetOrAddAudioSource(gameObject);
        audioSource.clip   = houseSound;
        audioSource.volume = 3f;
        audioSource.Play();
    }
 // Update is called once per frame
 void Update()
 {
     if (lever.leverWasSwitched && lever.leverIsOn && leverUp)
     {
         if (audioSource == null)
         {
             audioSource = SVUtilities.SetOrAddAudioSource(gameObject);
         }
         audioSource.clip   = leverUp;
         audioSource.pitch  = Random.Range(minPitch, maxPitch);
         audioSource.volume = volume;
         audioSource.Play();
     }
     else if (lever.leverWasSwitched && !lever.leverIsOn && leverDown)
     {
         if (audioSource == null)
         {
             audioSource = SVUtilities.SetOrAddAudioSource(gameObject);
         }
         audioSource.clip   = leverDown;
         audioSource.pitch  = Random.Range(minPitch, maxPitch);
         audioSource.volume = volume;
         audioSource.Play();
     }
 }
示例#4
0
 // Update is called once per frame
 void Update()
 {
     if (button.buttonPressed && buttonDown)
     {
         if (audioSource == null)
         {
             audioSource = SVUtilities.SetOrAddAudioSource(gameObject);
         }
         audioSource.clip   = buttonDown;
         audioSource.pitch  = Random.Range(minPitch, maxPitch);
         audioSource.volume = volume;
         audioSource.Play();
     }
     else if (button.buttonUnpressed && buttonUp)
     {
         if (audioSource == null)
         {
             audioSource = SVUtilities.SetOrAddAudioSource(gameObject);
         }
         audioSource.clip   = buttonUp;
         audioSource.pitch  = Random.Range(minPitch, maxPitch);
         audioSource.volume = volume;
         audioSource.Play();
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (grabbable.inHand)
        {
            if (audioSource == null)
            {
                audioSource        = SVUtilities.SetOrAddAudioSource(gameObject);
                audioSource.clip   = sliderClip;
                audioSource.volume = volume;
                audioSource.loop   = true;
            }

            audioSource.pitch = slider.value * (maxPitch - minPitch) + minPitch;
            if (!audioSource.isPlaying)
            {
                audioSource.Play();
            }
        }
        else
        {
            if (audioSource != null && audioSource.isPlaying)
            {
                audioSource.Stop();
            }
        }
    }
示例#6
0
    // Use this for initialization
    void Start()
    {
        MeshRenderer[] renderers = (MeshRenderer[])SVUtilities.AllComponentsOfType <MeshRenderer>(gameObject);
        this.modelMaterials = new Material[renderers.Length];
        for (int i = 0; i < modelMaterials.Length; i++)
        {
            this.modelMaterials[i] = renderers[i].material;
        }

        foreach (Material material in this.modelMaterials)
        {
            material.EnableKeyword("_EMISSION");
        }
        updatedColor = new Color(0, 0, 0);
    }
示例#7
0
    private void OnTriggerStay()
    {
        if (Input.GetKey(KeyCode.Q) && Time.time >= nextSoundTime)
        {
            audioSource      = SVUtilities.SetOrAddAudioSource(gameObject);
            audioSource.clip = soundOnHit;


            audioSource.pitch  = pitchAdjust;
            audioSource.volume = gain;
            audioSource.Play();

            // write down when we will be finished:
            nextSoundTime = Time.time + .01f;
            //Debug.Log(soundOnHit.length);
        }
    }
    private void OnCollisionEnter(Collision collision)
    {
        if (grabbable.inHand && hapticsOnCollision)
        {
            input.RumbleActiveController(vibrationLengthInSeconds);

            if (soundOnHit)
            {
                if (audioSource == null)
                {
                    audioSource      = SVUtilities.SetOrAddAudioSource(gameObject);
                    audioSource.clip = soundOnHit;
                }

                audioSource.pitch  = Random.Range(minPitch, maxPitch);
                audioSource.volume = volume;
                audioSource.Play();
            }
        }
    }
示例#9
0
    void Start()
    {
        leverHingeJoint = GetComponent <HingeJoint>();

        JointLimits limits = leverHingeJoint.limits;

        limits.max                = Mathf.Max(leverOnAngle, leverOffAngle);
        limits.min                = Mathf.Min(leverOnAngle, leverOffAngle);
        leverHingeJoint.limits    = limits;
        leverHingeJoint.useLimits = true;

        // Get a grabbable on the Lever or one of it's children. You could technically have the grabbable outside of the lever
        // And connect it with a fixed joint, if so just set grabbable to public and set it in editor.
        SVGrabbable[] grabbables = (SVGrabbable[])SVUtilities.AllComponentsOfType <SVGrabbable>(gameObject);
        Assert.IsFalse(grabbables.Length > 1, "SVLever only supports one grabbing surface at a time.");
        Assert.IsFalse(grabbables.Length <= 0, "SVLever requires a grabble component on it, or a child object, to function.");
        grabbable = grabbables[0];

        startingEuler = this.transform.localEulerAngles;

        UpdateHingeJoint();
    }
示例#10
0
    private void OnCollisionEnter(Collision collision)
    {
        // can't play if last one not finished:
        if (Time.time >= nextSoundTime)
        {
            audioSource      = SVUtilities.SetOrAddAudioSource(gameObject);
            audioSource.clip = soundOnHit;

            audioSource.pitch = pitchAdjust;
            float volume = collision.gameObject.GetComponent <Rigidbody>().velocity.magnitude / 3f + gain;
            if (volume > 1f)
            {
                volume = 1f;
            }
            audioSource.volume = volume;
            audioSource.Play();

            // write down when we will be finished:
            nextSoundTime = Time.time + .15f;
            //Debug.Log(soundOnHit.length);
        }
    }