예제 #1
0
        // Update is called once per frame
        void Update()
        {
            if (!started)
            {
                started = true;
                testSound.Play();
            }

            // Stop sound if it goes below a certain distance from 0
            float sqrDistance = pauseDistance * pauseDistance;

            if (testSound.PlayRate > 0.0f)
            {
                if (transform.position.sqrMagnitude < sqrDistance)
                {
                    testSound.Pause();
                }
            }
            else if (transform.position.sqrMagnitude >= sqrDistance)
            {
                testSound.UnPause();
            }
        }