Does UE4 have client-side prediction built in?

I’ve come up with a working solution and decided to post it - it may help someone who is struggling with the same issue. Here how it goes: you have a total of four Blueprints two of which are spawned on the client and the other two on the server:

Client:

  • BP_WarriorProxy : this one is just an
    empty pawn that the user controls
  • BP_WarriorController : player
    controller blueprint

Both are set up as “Default pawn class” and “Player controller class” in Game Mode.

Server:

  • BP_Warrior : this is the actual character with skeletal mesh, animations and all the other shiny stuff
  • BP_WarriorAI : an AI Controller class to control the character

Both are spawned and owned by the server.

The main idea is that the player is owning and controlling a proxy pawn which spawns the actual character and his AI controller (on the server) when the game begins. After that all the input received by the player controller is sent to the server and passed to AI controller which in return moves the actual character.

Here is BP_WarriorProxy:

It spawns both the character and his AI controller and saves them as variables for later use. Don’t forget to set both variables “Replicated” for later use.

And his controller BP_WarriorController:

Nothing special here: take users mouse click and send it to the server (vector would’ve been enough) where I take the AI controller from the proxy and call MoveToHitLocation event.

BP_WarriorAI :
I can not attach more screenshots but it’s rather simple: It has the same movement logic as in the TopDown template except that I use the MoveToLocation() method instead of SimpleMoveToLocation() which is important.

BP_Warrior :
This is the actual character with all the usual components like MovementComponent, SkeletalMesh etc.


Couple of problems I’ve encountered:

  • You need to put your camera on the proxy pawn instead of the character because later is spawned on the server and this combination does not work well.
  • I put the camera on the spring arm and I don’t know why but in this set up it’s arm length is completely ignored - I ended up with positioning the camera through it’s transform.
  • You also need to set your proxies position to the position of the character (camera movement, network relevancy etc.)

Altogether it feels like a hacky way to make smth. basic like moba-game so if you have any suggestions - I’m all ears.