예제 #1
0
    void move()
    {
        _sfx.VolumeController(0, 0.1f);


        //Frente, com joystick
        if (rewPlayer.GetButton("MoveFront"))
        {
            //Clip, source, bool
            if (_sfx.AudioIsPlaying(0, 1))
            {
                _sfx.StopSound(0);
                _sfx.Playsound(0, 0, false);
            }
            playerRb.MovePosition(transform.position + transform.right * _speed * Time.deltaTime);
        }

        //Trás, com joystick
        else if (rewPlayer.GetButton("MoveBack"))
        {
            if (_sfx.AudioIsPlaying(0, 1))
            {
                _sfx.StopSound(0);
                _sfx.Playsound(0, 0, false);
            }

            playerRb.MovePosition(transform.position - transform.right * _speed * Time.deltaTime);
        }

        if (!_sfx.AudioIsPlaying(0, 0))
        {
            _sfx.Playsound(0, 1, true);
        }
    }