void Update() { word = obj.getWord(); if (word != null && word != "") { switch (word) { case "left": print("Voice input : left"); break; case "right": print("Voice input : right"); break; case "down": print("Voice input : down"); break; case "up": print("Voice input : up"); break; } } }
void Update() { /* Instead of keyboard.. * * //Get our raw inputs * float x = Input.GetAxisRaw ("Horizontal"); * float y = Input.GetAxisRaw ("Vertical"); * */ word = obj.getWord(); float x = 0.0F; float y = 0.0F; if (word != null && word != "") { switch (word) { case "left": x = -1.0F; break; case "right": x = 1.0F; break; case "down": y = -1.0F; break; case "up": y = 1.0F; break; } } //Normalize the inputs Vector2 direction = new Vector2(x, y).normalized; //Move the player Move(direction); }