[Help] Clients Using Jetpack on Listen Server Can Fly Higher Than the Server

Jumpjet bugging somewhere posted by Xnar | blueprintUE | PasteBin For Unreal Engine 4 I have tried running this equation client side and server side but the results remain the same. The vertical distance the server can reach is substantially less than clients. I have also tried Launch Character but that flips my results to where the Server can fly higher than the clients. The results are more obvious when the players hold a forward directional input before and during the jetpack use. If players use the jetpack without directional input the vertical height is roughly the same.

The equation shown here attempts to simulate a jetpack with depreciating returns. As the player gains speed upward the jetpack becomes less effective at giving more altitude. Conversely when a player is falling the jetpack is at full force until the player starts to regain altitude.

The Pawn settings enabled Replicates and Replicates Movement. Disabled Physics.

I am stumped. Fix this issue and this game is good to go :cool:

bump any hints or ideas of where to look are appreciated. I’m currently dead in the water on this

It’s hard to make out your code by this snippet without any commenting. But you might want to use components and let the server handle the fuel consumption, the “jetpack enabled” boolean and “add impulse” to the player. The only thing the player controls is pushing the button to trigger the server sided event.

I’m unsure what you mean by “use components”. Otherwise I’ve tried this, running all the script on the server while only the client declares if the jetpack boolean is true/false; the results remain the same. Somehow the clients are still able to get higher heights than the server. I’ve tried running the math client side and then having the client tell the server to Add Force but again, the clients gain more height than the server.

I’ve tried using Add Force and Launch Character. With Add Force clients get higher but with Launch Character the Server gets higher. I can’t use Add Impulse because my pawns are not simulating physics.

edit I think my problem lies in what the server believes is the velocity of the pawn and what the client believes. My mind is currently blocked by the fact that the pawn Replicates Movement to the server. So the server and client are constantly battling what the velocity actually is…? Ultimately the jetpack may need a new approach on how it grants players lift.

Just remember on Multiplayer that even if the client replicates movement to the server, if you are changing the movement speed and that variable is not being set on the server you will end up with jittery movement as explained in some forum posts.

I have a feeling that this might be a similar problem to what you are experiencing and your solution might lie in those fixes.

You may need to do something like this for your calculations … look at the attached picture.

I can’t assist you more than that as your code snippet does not provide enough insight in to you project and the way you have wired things up. I did notice that none of your variable that control the jumpjet are replicated and this could also be a problem.

That is correct. All of my movement speed adjustments are being sent to the server such as when the player holds Shift to sprint.

The jumpjet variables are all default variables and never change throughout gameplay.

The pawn I am using is the First Person Character pawn from the UE4 First Person template. I have made no alterations to his movement controls that would affect his Z velocity, weight, or gravity scale. The only significant change is I enabled Replicates and Replicates Movement

I’ve updated my jumpjet blueprint to include comments. Client Side Jetpacks with Latency Offset posted by Xnar | blueprintUE | PasteBin For Unreal Engine

So far with my testing I have surmised the factor that is causing all this trouble is the Get Velocity from the Character Movement component. Because there is lag time, whether this script is run Client-side or Server-side, the delay between communication allows the velocity on both machines to develop discrepancies. The thrust granted by the jumpjets scales based on the current Z velocity of the pawn. The velocity discrepancy causes the height gained by the client or server to differ because during the lag time, the pawn is losing velocity which negates the effectiveness of the force applied by Launch Character.

For example, the client has a Z velocity of positive 200. The client runs the thrust scale math and sends the Launch Character command to the server. By the time the Server receives the command the client has actually lost velocity, say to a positive 150 and thus the Launch Character force will have less effect on the pawn. Because the force was less effective the expected ending height of 500 centimeters and a velocity of 250 from the acceleration, ends up being less at under 400 centimeters and the velocity is also less than 250. This creates a problem because now the next Launch Character request will scale to a higher because the client perceives less velocity…it is a compounding factor from there.