Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        //we need to make sure that the plane will always fall when nothing happens
        Vector3 newPos = new Vector3(0, transform.position.y - fallRate * Time.deltaTime);

        if (Microphone.devices.Length > 0) //if we have a microphone
        {
            float level = mic.GetVolumeMic();
            newPos.y += (level * speedMul) * Time.deltaTime;
        }
        else //if no microphone, use keyboard
        {
            newPos.y += (Input.GetAxis("Vertical") * speedMul) * Time.deltaTime;
        }
        transform.position = newPos; //where the plane goes
    }