vehicle movement commands in multiplayer?

I’m trying to get a vehicle to work in multiplayer. But I’m having issues with the player controls. If I send the player controls from the client to the server via RPC, the player gets kicked from the server because of RPC flooding. So how does a client send movement commands to the server to control a vehicle without RPC freaking out?

When you’re sending player controls from client to server via RPCs, do you mean a custom RPC or using the vehicle controls like SetThrottleInput?

How I’ve done vehicle controls in multiplayer is:

  • Make the player the net owner of the vehicle by calling SetOwner(SomePlayerController) on the vehicle server-side
  • Use the vehicle movement component’s existing functions like SetThrottleInput, SetSteeringInput, SetHandbrakeInput to control the vehicle

The first step ensures that the vehicle can send RPCs at all from the player’s client, we need that since the vehicle movement component uses internal RPCs for sending input. The Set___Input functions have internal checks so that they only send RPCs if a value needs to be sent. So while an input value stays the same it doesn’t resend it. That has worked for me so far. Does that help?

Unfortunately, explicitly setting the owner didn’t fix the problem. The client still gets kicked off the server when possessing the vehicle with the server complaining that the client is flooding RPC. The problem seems to lie with something going on in UWheeledVehicleMovementComponent::UpdateState.

Edit:
Looking a little deeper, it seems that UpdateState() calls ServerUpdateState which is an RPC. This happens unconditionally with every with tick.