コード例 #1
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space) && _groundChecker.CheckGround())
     {
         _rigidbody.AddForce(Vector2.up * JumpForce, ForceMode2D.Impulse);
     }
 }
コード例 #2
0
 private void TryMove()
 {
     if (_groundChecker.CheckGround())
     {
         _horizontalInput    = Input.GetAxis("Horizontal");
         _rigidbody.velocity = new Vector2(_horizontalInput * _speed, _rigidbody.velocity.y);
     }
 }
コード例 #3
0
ファイル: PlayerMovement.cs プロジェクト: hrederik/FirstTask
 private void Update()
 {
     if (Input.GetMouseButtonDown(0) && _groundChecker.CheckGround())
     {
         Jump();
     }
 }
コード例 #4
0
    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);
            }
        }
    }
コード例 #5
0
ファイル: PlayerMover.cs プロジェクト: lekss361/Runners
    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);
        }
    }