(I got the single jump working, the applying over time is still a problem)
Hello.
I’m trying to get some kind of force added to my character (and other objects) in my 2D Side Scroller prototype without it being influenced by the frame rate. I’ve tried AddForce/AddImpulse/Set Velocity with and without DeltaTime.
For the current situation (but not limited to, i.e. the same problem applies to throwing items in the game) I didn’t like the PaperCharacter Jump and JumpMaxHoldTime.
Upon triggering the InputAxis the new Jump gets called. By holding down the button some variable adds up and prevents the character from accelerating upwards at some point. When the character hits the ground the variabe is reset. Very similar to the in-built Jump, but I can control it better.
I posted a video yday that showed the “ideal” (for now) jumping for all framerates, tho movement here is a WiP as you see (getting stuck):
Everything worked wonderfully, I just noted that rarely it would freak out a bit or not jump the same height all the time.
I logged the height of my character jumps and then used Substepping which improved the similarity of jump heights a lot.
I had a long talk about this yday in Unrealslackers and while I got some interesting information overall, there was no solution to my problem. Searching about the topic brought me to the general idea that this is a problem in UE4. For example: How to make physics forces independent of frame rate?
While writing this I’m trying around in the editor as well to double check and I noted that I can make my single jump work with AddForce (tho for a single AddImpulse would make more sense and tho physics are already looking at DeltaTime, no?). And surprisingly by using GetWorldDeltaSeconds (or its calculation into the current FPS):
So this works in 30,60,120 FPS now, all the same height, for the initial jump.
But the same does not work apllied over time during the button-press (tho I thought that would be the perfect case for AddForce). MaxJumpHoldTime is 0.2 btw.
I also thought it might be a solution to take the current FPS and “invert” it’s value, starting from 119. 30 FPS would be a value of 90. 60 is 60, 90 is 30. And 119 is 1/1 is 119.
TestForce is simply the value of 119.
But at this point I think I’m just brainfarting around anyways. It didn’t work. I’ve sat at least 5 hours on this problem.
At the end the question is now: How do I make the part work that applies AddForce during the button-press/input axis. If it’s of importance: this has to work in multiplayer.