📜  grepper 如何与 wasd 一起行走 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:31.840000             🧑  作者: Mango

代码示例1
private void Update() {
         Rigidbody rb = GetComponent();
         if (Input.GetKey(KeyCode.A))
             rb.AddForce(Vector3.left);
         if (Input.GetKey(KeyCode.D))
             rb.AddForce(Vector3.right);
         if (Input.GetKey(KeyCode.W))
             rb.AddForce(Vector3.up);
         if (Input.GetKey(KeyCode.S))
             rb.AddForce(Vector3.down);