#Sloppy jumping

1 messages · Page 1 of 1 (latest)

vivid rapids
#

Hi, so i have a physics based movement system that works by applying a force. The same thing is also the case for jumping. However, when jumping if I have horizontal momentum(if I am pressing to go forward) every time I touch the ground even while holding down jump button my horizontal momentum gets reduced. I have no idea why this happens and also no idea how to fix it. Does anybody have any idea how I can solve this or just a different approach I should take to jumping or something idk. Here is the code:

        if (isGrounded && !isJumping) {
            isJumping = true;

            //Add jump forces
            rb.AddForce(Vector2.up * jumpForce * 1.5f ); // Jump relative to
            rb.AddForce(normalVector * jumpForce * 0.5f); // wall jumping? idfk
            
            // If jumping while falling, reset y velocity.
            Vector3 vel = rb.linearVelocity;
            if (rb.linearVelocity.y < 0.5f) // Reset y velocity if y velocity almost 0
                rb.linearVelocity = new Vector3(vel.x, 0, vel.z);
            else if (rb.linearVelocity.y > 0) // Half y velocity if y velocity not almost 0
                rb.linearVelocity = new Vector3(vel.x, vel.y / 2, vel.z);
        }
    }
lone pewter
#

every time I touch the ground even while holding down jump button my horizontal momentum gets reduced
Isn't that just friction?

vivid rapids
#

oh...

#

ur right...

hushed valley
#

kinda sounds like friction, have you tried reducing it (or increasing it a lot to see if that's the cause)

vivid rapids
#

But i have a physics material on the ground object that has the friction set to 0

hushed valley
#

oh praetor beat me to it, i didn't scroll down lol

lone pewter
vivid rapids
#

what should i show?

#

just the inspector window?

lone pewter
#

as much detail as possible

hushed valley
#

the rigidbody config, at least

lone pewter
#

and collider(s)

vivid rapids
hushed valley
#

you shouldnt have an RB and CC

lone pewter
#

the plaayer's collider and the Ground material too

#

The CC seems disabled and I'm hoping/assuming it's staying that way

vivid rapids
hushed valley
#

oh 3d rb doesn't have a material? TIL

lone pewter
vivid rapids
lone pewter
#

that's going to take the average of this friction (0) and the default material (not zero) and give you a not zero friction

vivid rapids
lone pewter
#

yeah the physics mat is on the collider in 3D

vivid rapids
#

imma try setting everythin to 0 on the physics material

#

there is no 0 ther

hushed valley
vivid rapids
#

omg

#

i think setting the friction combine solved it

#

to minimum

#

i wanna cry

#

its been 3 days

#

i thought it was my code

#

wow ok