/// <summary> /// Parse the button in put, and make it work with the grid movement. /// </summary> void ButtonInput() { MovementBehaviour.Directions temp = GetComponent <MovementBehaviour>().directionKey; MovementBehaviour movement = GetComponent <MovementBehaviour>(); bool tryChange = false; if (Input.GetKey(KeyCode.UpArrow)) { temp = MovementBehaviour.Directions.Up; tryChange = true; } if (Input.GetKey(KeyCode.DownArrow)) { temp = MovementBehaviour.Directions.Down; tryChange = true; } if (Input.GetKey(KeyCode.LeftArrow)) { temp = MovementBehaviour.Directions.Left; tryChange = true; } if (Input.GetKey(KeyCode.RightArrow)) { temp = MovementBehaviour.Directions.Right; tryChange = true; } if (tryChange) { movement.TryChangeDirections(temp, true); } }