Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (micsConnected)
     {
         float note = listener.getNote();
         pc.SetAngle(note * 30);
     }
 }
Exemplo n.º 2
0
    void Update()
    {
        if (!source.isPlaying)
        {
            source.Play();
        }
        timePassed += Time.deltaTime;
        if (timePassed >= analysisGap)
        {
            float   note      = getNote();
            Vector3 direction = new Vector3(0.0f, 0.0f, 0.0f);
            float   angle     = note * 30;
            pc.SetAngle(angle);
            if (!float.IsNaN(note))
            {
                Debug.Log(note);
                float theta = Mathf.Deg2Rad * angle;
                float z     = force * Mathf.Cos(theta);

                moveUpwards = (z > lastZ);


                float x = force * Mathf.Sin(theta);
                moveLeft = (x < 0);

                direction = new Vector3(x, 0.0f, z);
                Debug.Log(direction);
            }



            if (moveUpwards & moveLeft)
            {
                transform.Translate(new Vector3(moveSpeed, 0, moveSpeed));
            }
            else if (moveUpwards & !moveLeft)
            {
                transform.Translate(new Vector3(-moveSpeed, 0, moveSpeed));
            }
            else if (!moveUpwards & moveLeft)
            {
                transform.Translate(new Vector3(moveSpeed, 0, -moveSpeed));
            }
            else if (!moveUpwards & !moveLeft)
            {
                transform.Translate(new Vector3(-moveSpeed, 0, -moveSpeed));
            }
            //rb.velocity = direction;
        }
    }
Exemplo n.º 3
0
    void Update()
    {
        float newNote = listener.getNote();

        if (!float.IsNaN(newNote))
        {
            lastNote = newNote;
        }
        float note = lastNote;

        pc.SetAngle(newNote * 30);
        float   theta     = Mathf.Deg2Rad * note * 30;
        float   z         = force * Mathf.Cos(theta);
        float   x         = force * Mathf.Sin(theta);
        Vector3 direction = new Vector3(x, 0.0f, z);

        rb.velocity = direction;
    }