diff options
author | chai <215380520@qq.com> | 2024-03-13 11:00:58 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2024-03-13 11:00:58 +0800 |
commit | 6ce8b9e22fc13be34b442c7b6af48b42cd44275a (patch) | |
tree | b38119d2acf0a982cb67e381f146924b9bfc3b3f /GenericInputHandler.cs |
+init
Diffstat (limited to 'GenericInputHandler.cs')
-rw-r--r-- | GenericInputHandler.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/GenericInputHandler.cs b/GenericInputHandler.cs new file mode 100644 index 0000000..deeed7e --- /dev/null +++ b/GenericInputHandler.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +public class GenericInputHandler : MonoBehaviour +{ + public Vector3 inputDirection; + + public bool normalized; + + public bool space; + + private void Start() + { + } + + private void Update() + { + space = Input.GetKey(KeyCode.Space); + inputDirection = Vector3.zero; + if (Input.GetKey(KeyCode.W)) + { + inputDirection += Vector3.forward; + } + if (Input.GetKey(KeyCode.S)) + { + inputDirection += Vector3.back; + } + if (Input.GetKey(KeyCode.D)) + { + inputDirection += Vector3.right; + } + if (Input.GetKey(KeyCode.A)) + { + inputDirection += Vector3.left; + } + if (normalized) + { + inputDirection = inputDirection.normalized; + } + } +} |