summaryrefslogtreecommitdiff
path: root/GenericInputHandler.cs
blob: deeed7e477ae247004bddd252b1d926945cafbc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
		}
	}
}