using System; using UnityEngine; namespace UnityStandardAssets._2D { [RequireComponent(typeof (PlatformerCharacter2D))] public class Platformer2DUserControl : MonoBehaviour { private PlatformerCharacter2D m_Character; private bool m_Jump; private void Awake() { m_Character = GetComponent(); } private void Update() { if (!m_Jump) { // Read the jump input in Update so button presses aren't missed. // @yingshaoxo m_Jump = Input.GetButtonDown("Jump"); //m_Jump = Input.GetButtonDown("Jump"); } } private void FixedUpdate() { // Read the inputs. bool crouch = Input.GetKey(KeyCode.LeftControl); float h = Input.GetAxis("Horizontal"); // Pass all parameters to the character control script. m_Character.Move(h, crouch, m_Jump); m_Jump = false; } } }