I’m trying to prototype a jumping system like Jump King from scratch. I created a Pawn without the Floating Pawn Movement. Then I changed the following:
With this setup, the cube movement does not respond properly. It looks like there’s always a horizontal force acting on the opposite side of the input, dragging the cube back. When increasing the movement input, the cube starts to lag or not move at all after some inputs.
After some testing, I discovered that:
It happens when physics and gravity are enabled at the same time. If one or other is disabled, the movement works perfectly. However, I need both to implement the jumping system.
Changing the cube to a sphere and disabling the Sweep on the Add Actor Local Offset make the movement works. But my character needs to be blocked during movement, so it must be enabled.
Any ideas about this behavior? Is it intended? (Should I study more physics) Should I try using another approach?
Hey there @Katreque1! Welcome to the community! So one of the bigger things is trying to mix physics sim with manual offsets is going to result in some weirdness, as generally if you’re controlling things purely by physics you would use something like Addforce to cause movement. In your case however you are doing the equivalent of teleporting by offset (That’s how the physics system sees it at least). Jump King and games like it look like they use built in physics, but many of them either don’t or heavily influence it for a specific feel.
Judging by the way Jump King looks is that each of these are actually handled via a specific formula when the jump is made, and when collisions occur you see a consistent bounce. This is not usually as simple to pull off in the built in physics for game engines. That said if you wanted to do this physically you can and you’ll get far more organic results from it, but it’ll be harder to pull off consistently.
If you want to go the physics route, you lose more accurate control but have to end up doing less math to handle the jump, fall, and bounces.
If you want to go custom, you’ll have to handle the math for everything, but you instead get 1:1 control of how the “”“Physics”“” react.
You could technically handle movement as a hybrid like this but disabling physics when your character is on the ground, then just enabling them on launch, but that seems like more work than it’s worth in my opinion.
Thanks for the response @SupportiveEntity. I didn’t know about this weird behavior when mixing both. Good to know!
I did some implementations yesterday and got basically what you said:
I created a Character using the Character Movement and it’s builtin functions. I got some good results. It was easy to implement and with some small pitfalls.
Then I tried to implement all the Physics by hand and apply it using the offsets per tick. After some read and math formulas, the results were great. But took a lot of time and tweaking to make it work properly.
Again, thanks for the insights. I spent some good time trying to figure out the best way to do it and your reply helped me a lot with it.
No problem! It’s usually a matter of deciding which is better for your use case, and I think if you’re doing a “Getting over it” pure physics is alright but knowing you have a jump is less consistent, but jump king’s jumps are so clean and deliberate to get the same effect with built in physics is harder, so a little math up front to make the jumps feel good and you’re on your way! If you have any more questions, don’t hesitate to ask!