Пример #1
0
    void FixedUpdate()
    {
        RaycastHit LHit;
        RaycastHit RHit;

        if (ikControll)
        {
            if (Physics.Raycast(transform.position + new Vector3(-0.25f, 1.5f, 0f), -transform.up + new Vector3(0f, 0.5f, 0f), out LHit, 1f) && move.turnright == false && move.IsGrounded() == false)
            {
                useIK       = true;
                rightHandIK = true;
                leftHandIK  = true;
                leftHandPos = LHit.point;
            }
            else
            {
                rightHandIK = false;
                leftHandIK  = false;
            }

            if (Physics.Raycast(transform.position + new Vector3(0.25f, 2.0f, 0f), -transform.up + new Vector3(0f, 0.0f, 0.0f), out RHit, 1f) && move.turnright && move.IsGrounded() == false)
            {
                useIK        = true;
                rightHandIK  = true;
                leftHandIK   = true;
                rightHandPos = RHit.point;
                leftHandPos  = LHit.point;
            }
            else
            {
                rightHandIK = false;
                leftHandIK  = false;
            }
        }

        if (useIK)
        {
            move.gravity          = 0;
            move.speed            = 0;
            move.rbody.useGravity = false;
            IkTimer += Time.deltaTime;
            if ((Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.Space)) && IkTimer > 0.5)
            {
                move.speed            = 1;
                move.rbody.useGravity = true;
                useIK      = false;
                ikControll = false;
                IkTimer    = 0;
            }
        }

        if (!useIK)
        {
            if (move.IsGrounded())
            {
                ikControll = true;
            }
        }
    }