예제 #1
0
    void Update()
    {
        RaycastHit2D hit = _raycast2D.Ray2D(transform.position, Vector2.down, _rayDistance, _layer, Color.red);

        if (hit.collider == null && Input.GetKeyDown(KeyCode.S))
        {
            _golpe = true;
        }
    }
예제 #2
0
    void Update()
    {
        if (_canDoJump)
        {
            Vector2      pos       = transform.position;
            Vector2      direction = Vector2.right * transform.localScale.x;
            RaycastHit2D hit       = _ray.Ray2D(pos, direction, _rayDistance, _wjLayer, Color.blue);

            if (Input.GetAxis("Vertical") > 0 && hit.collider != null)
            {
                _rgb.velocity        = new Vector2(_speed * hit.normal.x, _speed * _jumpForce);
                transform.localScale = (transform.localScale.x == 1) ? new Vector3(-1, 1, 1) : Vector3.one;
                _moves.enabled       = false;
            }
            else if (_jump._grounded)
            {
                _moves.enabled = true;
            }
        }
    }