using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;


    [RequireComponent(typeof(CharacterMovement))]
    public class CharacterControl: MonoBehaviour {
        private CharacterMovement character;
        private bool jump;

        private void Awake() {
            character = GetComponent<CharacterMovement>();
        }

        private void Update() {
        if(!jump) { // Read the jump input in Update so button presses aren't missed.
            jump = Input.GetButtonDown("Jump");
        }
        }

        private void FixedUpdate() {
            // Read the inputs.
            bool crouch = Input.GetKey(KeyCode.LeftControl);
            float h = CrossPlatformInputManager.GetAxis("Horizontal");
            // Pass all parameters to the character control script.
            character.Move(h, crouch, jump);
            jump = false;
        }
    }

