I have noticed that my character jumps at different heights depending on my project’s frame rate. Is there a good way to make sure that the jump function always sends the character pawn the same height upwards? This issue makes game progress impossible at a low frame rate.
It took me a great deal of time and effort, but I finally found the solution. Now my character always jumps a specified height over a specified amount of time.
Unfortunately, it seems as though the built-in jump function always uses velocity to make your character jump. Therefore, even when using delta time to balance things out, the jump height will always vary based on the framerate. The solution is to use a timeline. Here’s what I did:
When my character jumps, he sets a target Z based on a distance from his current Z. Then, the movement component gets switched to flying mode. (otherwise, he cannot be lifted off the ground.) Then, a timeline sweeps from 0 to 1 over the course of .3 seconds. Then, the Set Actor Location node is used each frame for the duration of the timeline, setting the actor’s Z location upwards as the timeline animates. When the timeline ends, the actor’s movement component gets set to falling mode until the actor gets close to the ground. I use a line trace to determine this. When the actor gets close to the ground, his movement component mode is switched to walking.
By using the timeline system in combination with switching the movement component mode, I can set specific time and height parameters for how my character will jump! I hope this info ends up being useful to someone else.