public IEnumerator MoveUpOnW() { yield return(null); unityInput.KeyPressed(KeyCode.W).Returns(true); player.Contruct(unityInput); Assert.AreEqual(new Vector3(0, 0, 0), player.GetComponent <Rigidbody>().velocity); yield return(null); Assert.AreEqual(new Vector3(0, 0, player.moveSpeed), playerGameObject.GetComponent <Rigidbody>().velocity); }
/// <summary> /// Updates Player 1's movement and facing rotation using the WASD keys and drops bombs using Space /// </summary> private void UpdatePlayer1Movement() { if (unityInput.KeyPressed(KeyCode.W)) //Up movement { rigidBody.velocity = new Vector3(rigidBody.velocity.x, rigidBody.velocity.y, moveSpeed); myTransform.rotation = Quaternion.Euler(0, 0, 0); animator.SetBool("Walking", true); } if (unityInput.KeyPressed(KeyCode.A)) //Left movement { rigidBody.velocity = new Vector3(-moveSpeed, rigidBody.velocity.y, rigidBody.velocity.z); myTransform.rotation = Quaternion.Euler(0, 270, 0); animator.SetBool("Walking", true); } if (unityInput.KeyPressed(KeyCode.S)) //Down movement { rigidBody.velocity = new Vector3(rigidBody.velocity.x, rigidBody.velocity.y, -moveSpeed); myTransform.rotation = Quaternion.Euler(0, 180, 0); animator.SetBool("Walking", true); } if (unityInput.KeyPressed(KeyCode.D)) //Right movement { rigidBody.velocity = new Vector3(moveSpeed, rigidBody.velocity.y, rigidBody.velocity.z); myTransform.rotation = Quaternion.Euler(0, 90, 0); animator.SetBool("Walking", true); } if (canDropBombs && unityInput.KeyDown(KeyCode.Space)) //Drop bomb { DropBomb(); } }