So I’ve coded a few basic platformers with an updated position for movement and stuff, and I wanted to try using the rigid body approach, and it quickly became clear I had no clue what I was doing. My Question:
How do I make my character jump further (not higher) when they’re running, while making it still feel good? I would love someone to help me understand what the math is doing better. Despite my best efforts, I feel as though I’m still largely guessing or using nonsense.
My Code: ```csharp
**// Jumping while running
if (Input.GetButtonDown(“Jump”) && onGround == true && isRunning == true)
{
isRunning = true;
rb.AddForce(Vector2.up * jumpForce * 1.2f, ForceMode2D.Impulse);
So i dont have an exact answer cause there are probably a few ways to do it. But if you have a isRunning bool or something that determines when the player is running, you can have a condition where if you press jump while isRunning is true, it goes further. To do this you can add force not just up but also forward so it makes them go farther horizontally. Thats what i thought of off the top of my head
I have tried this before and now and it doesn’t seem to change the jump at all, I am guessing because of the gravity modifiers?
I’ve tried things along the lines:
I just can’t find the answer to ‘how do I jump further not higher’ on anything. EVERYONE just talks about gravity modifiers depending on how long you hold the jump input. Will someone at least explain to me why what I’m asking is so difficult to answer? It’s driving me insane.
If you think its because of the gravity then just increase the jumpForce variable. I would actually create another variable so you can have it differ from the vertical jumpForce. Increase the new one so until you see a noticeable difference.
Additionally, there could be a weird friction issue occurring if the horizontal force gets added immediately and kills the forward momentum because of the ground. You may have to delay the horizontal force a fraction of a second after your vertical force.