Exemple #1
0
    void Jump()
    {
        if (states.vertical > 0)
        {
            if (!justJumped)
            {
                justJumped = true;

                if (states.onGround)
                {
                    anim.JumpAnim();

                    rb.velocity     = new Vector3(rb.velocity.x, this.jumpSpeed);
                    jmpTimer        = 0;
                    canVariableJump = true;
                }
            }
            else
            {
                if (canVariableJump)
                {
                    jmpTimer += Time.deltaTime;

                    if (jmpTimer < this.jumpDuration / 1000)
                    {
                        rb.velocity = new Vector3(rb.velocity.x, this.jumpSpeed);
                    }
                }
            }
        }
        else
        {
            justJumped = false;
        }
    }
Exemple #2
0
    void Jump()
    {
        // jump script that checks if the player wishes to jump, if they can jump and controls velocity and direction
        if (states.vertical > 0)
        {
            if (!justJumped)
            {
                justJumped = true;

                if (states.onGround)
                {
                    audioManager.soundPlay("Effect_Jump");
                    anim.JumpAnim();
                    rb.velocity    = new Vector3(rb.velocity.x, this.jumpSpeed);
                    jumpTimer      = 0;
                    canVaribleJump = true;
                }
            }
            else
            {
                if (canVaribleJump)
                {
                    jumpTimer += Time.deltaTime;
                    if (jumpTimer < this.jumpDuration / 1000)
                    {
                        rb.velocity = new Vector3(rb.velocity.x, this.jumpSpeed);
                    }
                }
            }
        }
        else
        {
            justJumped = false;
        }
    }
Exemple #3
0
    void Jump()
    {
        if (states.vertical > 0)
        {
            if (!justJumped && states.onGround) // old physics
            {
                anim.JumpAnim();

                rb.velocity     = new Vector2(rb.velocity.x, 4f);
                jumpTimer       = 0;
                canVariableJump = true;
            }

            /*if (!justJumped)
             * {
             *  justJumped = true;
             *
             *  if (states.onGround)
             *  {
             *
             *      anim.JumpAnim();
             *
             *      rb.velocity = new Vector3(rb.velocity.x, this.jumpSpeed);
             *      jumpTimer = 0;
             *      canVariableJump = true;
             *  }
             * }
             * else
             * {
             *  if (canVariableJump)
             *  {
             *      jumpTimer += Time.deltaTime;
             *
             *      if (jumpTimer < this.jumpDuration / 1000)
             *      {
             *          rb.velocity = new Vector3(rb.velocity.x, this.jumpSpeed);
             *      }
             *  }
             * }*/
        }
        else
        {
            justJumped = false;
        }
    }
    void Jump()
    {
        if (states.vertical > 0)
        {
            // con este se salta
            if (!justJumped)
            {
                justJumped = true;

                // si el character esta en el suelo, empieza la animacion del salto
                if (states.onGround)
                {
                    anim.JumpAnim();

                    // dependiendo de la velocidad que tenga el character al andar, saltara mas lejos
                    rb.velocity     = new Vector3(rb.velocity.x, this.jumpSpeed);
                    jumpTimer       = 0;
                    canVariableJump = true;
                }
                else
                {
                    // esto pone la fuerza de salto
                    if (canVariableJump)
                    {
                        jumpTimer += Time.deltaTime;

                        if (jumpTimer < this.jumpDuration / 1000)
                        {
                            rb.velocity = new Vector3(rb.velocity.x, this.jumpSpeed);
                        }
                    }
                }
            }
            else
            {
                justJumped = false;
            }
        }
    }