innomotion media
innomotion media

Reputation: 922

Unity: Player jumps fine, but falls extremly slow

I am currently building a little 2D platformer with a character that can jump. This is how the jumping looks (FixedUpdate):

    if (jump)
    {

        if (isGrounded)
        {
            isGrounded = false;

            rb.AddForce(Vector2.up * (jumpHeight * counterForJumpHeight) * Time.deltaTime, ForceMode2D.Impulse);
            jump = false;

            anim.SetBool("bool_anim_isJumping", true);
        }

        if (timer != null)
            timer.Stop();

        counterForJumpHeight = jumpMulitMin;

        jumpAlreadCharging = false;

    }

Looks perfect for every jump up and then falling back down.

HOWEVER: when the player JUST falls (like off a cliff oder something) without a jump it looks like he has the mass of a leaf. Sailing to the ground extremley slowly. Not accelerating at all. Just falling as in slow motion. Of course I can up the gravity, but that also affects the falling AFTER my jump and makes him look like a stone. As if the falling is sped up or something. But that doesnt make sense. Him falling AFTER a jump and him just falling off of something SHOULD look the same, right? But it doesnt.

These are my values for the RB:

enter image description here

Upvotes: 1

Views: 4462

Answers (4)

innomotion media
innomotion media

Reputation: 922

it was all my fault, there was no way of guessing it from your point of view. Everything the player could jump from was tagged with "can_jump".

void OnCollisionEnter2D(Collision2D col)
{
    if (col.gameObject.tag == "can_jump") // detect collision with ground game object 
    {
        isGrounded = true;
        deacceleratePerFrame = 1.5f;
        anim.SetBool("bool_anim_isJumping", false);
    }

}

This includes all edges. Removing this means I cannot jump atm anymore, however this caused the issue. I sure find another way :-) thank you all

Upvotes: 2

Horothenic
Horothenic

Reputation: 678

It can be a problem with the animator, if the animation contains changes to Rigidbody, it does weird stuff if you have set the Make Default in animation.

Upvotes: 1

KillerHawk
KillerHawk

Reputation: 33

I'm not 100% sure but this may have to do with the collision detection. Try changing the setting to continuous dynamic instead of discrete.

Upvotes: 1

Breizhpanda
Breizhpanda

Reputation: 11

YOu can either up your player's rigidbody Mass, or increase gravity in edit/projectsettings/ physics

Upvotes: 1

Related Questions