You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
1.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Debug class for controlling a character with keyboard input
/// </summary>
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<Character>();
}
#endregion Unity Functions
}