using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// Debug class for controlling a character with keyboard input /// public class KeyboardInput : MonoBehaviour { #region Inspector Fields [SerializeField] [Tooltip("Character to move")] private Character character; public float characterSpeed; #endregion Unity Functions #region Unity Functions // Update is called once per frame void Update() { if (character == null) return; if (Input.GetKeyDown(KeyCode.LeftArrow)) { StartCoroutine(character.RotateToDirection(Direction.Left, Character.Animation.Jump, characterSpeed, true)); } if (Input.GetKeyDown(KeyCode.RightArrow)) { StartCoroutine(character.RotateToDirection(Direction.Right, Character.Animation.Jump, characterSpeed, true)); } if (Input.GetKeyDown(KeyCode.UpArrow)) { float outTime; Move move = (Move)ScriptableObject.CreateInstance(typeof(Move)); StartCoroutine(move.Run(character, characterSpeed)); Destroy(move); } if (Input.GetKeyDown(KeyCode.Space)) { float outTime; Jump jump = (Jump)ScriptableObject.CreateInstance(typeof(Jump)); StartCoroutine(jump.Run(character, characterSpeed)); Destroy(jump); } } //if character is empty check on object for it private void OnValidate() { if (character == null) character = GetComponent(); } #endregion Unity Functions }