void Update() { if (Input.GetKeyDown(KeyCode.Space) && _groundChecker.CheckGround()) { _rigidbody.AddForce(Vector2.up * JumpForce, ForceMode2D.Impulse); } }
private void TryMove() { if (_groundChecker.CheckGround()) { _horizontalInput = Input.GetAxis("Horizontal"); _rigidbody.velocity = new Vector2(_horizontalInput * _speed, _rigidbody.velocity.y); } }
private void Update() { if (Input.GetMouseButtonDown(0) && _groundChecker.CheckGround()) { Jump(); } }
private void Update() { _rigidbody.velocity = new Vector2(_speed * Time.deltaTime, _rigidbody.velocity.y); if (Input.GetKeyDown(KeyCode.Space)) { if (_groundChecker.CheckGround() || _obstacleChecker.CheckObstacle()) { _rigidbody.AddForce(Vector2.up * _jumpForce, ForceMode2D.Impulse); } } }
private void Update() { _rigidbody.transform.position = transform.position + new Vector3(_moveSpeed * Time.deltaTime, 0, 0); _animator.SetBool("Ground", true); if (Input.GetKeyDown(KeyCode.Space)) { if (_groundChecker.CheckGround()) { _rigidbody.AddForce(Vector2.up * _jumpForce, ForceMode2D.Force); _animator.SetBool("Ground", false); } } if (Input.GetKeyDown(KeyCode.LeftControl) && _timer.SPWR()) { bool presskey = true; _timer.PressKey(presskey); } }