diff options
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; + } + } +} |