private float SPEED = 0.01f; private float JUMP = 2.0f; private int ground = 0; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { Vector2 position = transform.position; if (Input.GetKey(KeyCode.RightArrow)) { position.x += SPEED; } if (Input.GetKey(KeyCode.LeftArrow)) { position.x -= SPEED; } if (Input.GetKeyDown(KeyCode.LeftControl)) { if (ground == 0) { Debug.Log("Jump"); position.y += JUMP; } } transform.position = position; } void OnTriggerStay2D(Collider2D col) { if (col.tag == "Ground") { ground = 0; } } void OnTriggerExit2D(Collider2D col) { if (col.tag == "Ground") { ground = 1; } }