Ejemplo n.º 1
0
    void FixedUpdate()
    {
        Debug.Log(rb.velocity);
        if (wantJump)
        {
            currentParav = upParav;
            jumpEvent?.Raise(upParav.getTimeToPeak(pVel.maxVelocity));
            if (rb.velocity.y < 0)
            {
                rb.velocity += Vector2.down * rb.velocity.y;
            }

            rb.velocity += currentParav.getStartingVelocity(pVel.maxVelocity) * Vector2.up;
        }
        if (rb.velocity.y < 0 && previousVel.y >= 0)
        {
            handlePeak();
        }
        if (rb.velocity.y != 0)
        {
            rb.gravityScale = currentParav.getGravScale(pVel.maxVelocity);
        }
        else
        {
            rb.gravityScale = 1;
        }
        wantJump    = false;
        previousVel = rb.velocity;
    }
Ejemplo n.º 2
0
 private void handlePeak()
 {
     currentParav    = fallParav;
     rb.gravityScale = currentParav.getGravScale(pVel.maxVelocity);
 }