Example #1
0
    private void Physics()
    {
        if (!dead)
        {
            if (CC.isGrounded)
            {
                Jumps         = MaxJumps;
                VerticalForce = 0;
                AnimS.Refresh(false, "Salto");
                UsedWJ = false;
            }

            Vector3 mov = Vector3.zero;
            if (Input.GetKeyDown(Jumpbutton) || FlynnInput.instance.JumpDown)

            {
                if (Jumps > 0)
                {
                    //aca para bajar plataformas
                    if (TakeSlideInput())
                    {
                        gameObject.layer = AcrossPlatformsLayer;
                        ChrouchingJump   = true;
                        Invoke("StopCJ", CJDuration);
                    }
                    else
                    {
                        VerticalForce += JumpSpeed;
                        Jumps--;
                        gameObject.layer = AcrossPlatformsLayer;
                        AnimS.Refresh(true, "Salto");
                    }
                }
                else if (WallJump && Wall && !UsedWJ)
                {
                    VerticalForce    = JumpSpeed;
                    gameObject.layer = AcrossPlatformsLayer;
                    AnimS.Refresh(true, "Salto");
                    UsedWJ = true;
                }
            }

            if (Time.timeScale != 0f)
            {
                VerticalForce -= Gravity;
            }
            if (VerticalForce <= 0 && !ChrouchingJump)
            {
                gameObject.layer = DefaultLayer;
            }
            mov += Vector3.down * -VerticalForce;
            mov += Front * TakeHorizontalInput() * HorizontalSpeed;
            if (!isGrounded && ApplySlide)
            {
                mov.z += (1f - hitNormal.y) * hitNormal.z * (1f - slideFriction) * slideMultiplier;
            }
            CC.Move(mov * Time.deltaTime);
            isGrounded = (Vector3.Angle(Vector3.up, hitNormal) <= slopeLimit);
        }
    }