Networking a flight mechanic

I’ve got this flying code that I’m trying to replicate for a networked multiplayer game. It works fine locally, but, because I update the velocity vector at 60fps, I end up with some steep bandwidth requirements.

Inside of the ‘New Velocity’ collapsed node, I use player input and the previous frame’s velocity to calculate the direction & velocity of the character in-flight. This means that I have to send a ton of data upstream and that it has to be sent back downstream as well.

Is there any way I can optimize this?

Wouldn’t it be better if you can make the velocity variable replicated instead of doing RPCs on such high frequency.

I don’t know about this but last I heard they were introducing NetQuantize Vectors in blueprints as well they save you bandwidth.

Lol On a different note I think we have talked before on discord regarding some dragon game called ‘Tasneem’ or something I recognize your name. maybe wrong on that.

Oh man hey :rofl: yeah I remember your name! Yeah this is actually the flight code from Soar, I’m using it as a tool to teach myself networking. The game is still under development I just gave up on documenting it lol.

So the velocity variable itself is part of the CharacterMovementComponent, I don’t think I can make that replicated without messing with the engine source code, and idk how well that’d work. I could potentially break the node out into a variable, which does remove the upstream bandwidth but still retains the downstream- because the current velocity is dependent on the previous frame velocity. Even then though synchronicity remains a huge problem because any drop will cause the client-side calculation to totally lose track of the server.

So, ultimately I ended up using GPT-4 to help me out and this is the solution I found:

Instead of calculating velocity and rotation on the client and passing it to the server I now only pass player input (on tick) and handle calculations server-side. While the Velocity variable isn’t itself replicated, the rest of the CharacterMovement component is, so I can simply set it on the server and let CMC handle replication. Rotation on the other hand has to be set client-side.

Movement is smooth as you’d expect from CMC, but rotation is choppy so I plan to implement client-side prediction algorithm at some point in the future. At least it’s playable now!

Hey man, I would really like to ask for your help and knowledge you got from replicating flight physics. I’m actually also creating a flight sim but as a mod to one milsim game and I’ve got basically one BIG function where every force is calculated in one vector which I then apply as a movement and rotation, but how to replicate all that would be 1000x worse than if replicating helicopter’s movement with movement component .

So one developer told me use my raw acceleration,roll,pitch,yaw as replicated inputs sent to the server which then are used in calculation server-side which will be the most correct one, and if there is desync from client-side I’d just interpolate to the server’s-side one …

If you have a finished replicatede logic, I would be more that apprecitive for your help, here is my discord: qurtski