x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Does UE4 have client-side prediction built in?

This UE3 doc says that it is implemented in UnrealScript in the PlayerController script. http://udn.epicgames.com/Three/NetworkingOverview.html#Player Movement and Prediction

I assume this is still present, but nothing networking related is mentioned anywhere in the features page and the documentation doesn't mention prediction. The recent Blueprint Networking video tutorials also don't bring it up (I didn't watch all of them though).

If it is included I would think it would be something they advertise, since Unity's networking implementation is not great and you don't have enough access to their physics to make client-side prediction doable at all.

Product Version: Not Selected
Tags:
more ▼

asked Apr 24 '14 at 05:06 AM in Using UE4

avatar image

JonTronne
79 2 6 9

avatar image Purepower Sep 15 '14 at 06:21 AM

You could try this:

alt text

(comments are locked)
10|2000 characters needed characters left

7 answers: sort voted first

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: alt text 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: alt text 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.

more ▼

answered Jun 06 '14 at 08:37 AM

avatar image

Alex.Holyman
208 14 17 27

avatar image Nylira Jul 06 '14 at 06:32 AM

Hi ggs_alex, I'm trying to replicate your solution and I'm stuck on the BP_WarriorController blueprint. Specifically, what does "Event Move To Location" do? Is it a function? What's inside it?

avatar image Alex.Holyman Jul 10 '14 at 11:30 AM

Hm. It's actually in the screenshot: "EventMoveToLocation" in the BP_WarriorController is a replicated event that executes on the server. It just takes the controlled pawn, casts it to BP_WarriorProxy (remember that BP_WarriorController controlls the proxy pawn), takes the AIController (which we saved previously) and basically calls its MoveToLocation method (which in the screenshot is wrapped into EventMoveToHitLocation but that's not important). I know, it's confusing but if you grasp the idea of who-controls-whom you can implement it your own way. Our current implementation for example does not need the proxy pawn and still works fine.

avatar image drone.ah Aug 30 '14 at 03:45 AM

Thank you. This was a massive help. I managed to do this in C++ and posted a howto

avatar image Amelia_Synapse Sep 19 '16 at 08:22 PM

Hello :)

First of all thank you very much for your help on this! The solution you posted has been fantastic.

I am, however, having problems setting up the proxy. I have posted my question here: https://answers.unrealengine.com/questions/491420/how-do-you-set-up-a-camera-on-a-proxy-pawn-for-a-c.html

If you have the time and notice any reasons why this isn't working, I'd greatly appreciate the help. Alternatively, if you know of any tutorials that could be useful to watch as I try to problem solve - please let me know :)

(comments are locked)
10|2000 characters needed characters left

Yes, player movement replication and prediction is implemented in UE4 as Rama points out.

However it has changed locations from the days of UE3 (where it was in the PlayerController) to the CharacterMovementComponent for Characters in UE4. Prediction and correction when the character strays too far from the server's authoritative position is implemented, as well as a Client authoritative mode that can be enabled. It's fairly complex, but you can get a grasp of it by looking at the INetworkPredictionInterface implementation in UCharacterMovementComponent, as well as the related SavedMove processing in there that replays moves on the client when they receive a correction.

Vehicles using UWheeledVehicleMovementComponent also support replication to/from the server basically by replicating the input which drives the remote simulations. This is a simpler example but may server as a good starting point.

more ▼

answered Apr 24 '14 at 06:28 PM

avatar image

LEGO_MANIAC STAFF
1k 18 16 39

avatar image zoid May 06 '14 at 05:14 PM

Is the replication and prediction handled by transmitting input events or movement impulses and then the movement component executes the movement on both client and server?

avatar image LEGO_MANIAC STAFF May 06 '14 at 05:59 PM

Is the replication and prediction handled by transmitting input events or movement impulses and then the movement component executes the movement on both client and server?

Yes, that's correct. For characters it sends position and acceleration (where acceleration is the result of input), for vehicles it sends the input params (acceleration, braking, steering, etc).

avatar image Alex.Holyman May 27 '14 at 03:10 PM

How does the prediction work in combination with path finding? There seems to be a lot of trouble making that work - there are several posts here and in the forum about it. My idea was to send the hit location to the server, use SimpleMoveToLocation() on the server to move the character and everything else should work over the character replication. Basically that works but the movement is "jerky and jittery". Is that an unreal bug or just a wrong approach?

avatar image LEGO_MANIAC STAFF May 27 '14 at 05:46 PM

When you're trying to move the local player, you should perform the movement on both the server and the client to keep them in sync. The server will correct the client to the server-authoritative position if there is a large enough error, but if the client isn't trying to do what the server is dong, those corrections will be constant and it will look jittery.

If you use the console command "p.netshowcorrections 1" you should see some logs and debug displays of corrected movement. If you set things up correctly, ideally you wouldn't see any at all.

avatar image LEGO_MANIAC STAFF May 27 '14 at 06:51 PM

To follow up: I just realized that if you are using Path Following (SimpleMoveToLocation()), there may be issues w/ using that on a client in network games. I'm trying to get clarification from some folks and I will follow up!

avatar image Alex.Holyman May 28 '14 at 07:57 AM

You're right - when the server character is moving there are no corrections at all. But when the client is moving - there are corrections practically every frame.

avatar image Alex.Holyman May 28 '14 at 07:34 AM

Hi Zak, thank you very much for the answer. This issue is kind of driving me crazy. It seems like I'm not alone but there were no help so I hope you can provide some clarification.

avatar image Exreph May 28 '14 at 04:54 PM

Yup, I'm in same boat. Thanks Zak! Looking forward to any more information on SimpleMoveToLocation Replication.

avatar image Alex.Holyman Jun 02 '14 at 12:39 PM

Keep-alive-message. Just to make sure this thread is not forgotten

avatar image LEGO_MANIAC STAFF Jun 02 '14 at 07:28 PM

I'm waiting to hear back from the AI/PathFollowing experts, I will ping them again.

avatar image MieszkoZ STAFF Jun 03 '14 at 12:30 PM

SimpleMoveToLocation was never intended to be used in a network environment. It's simple after all ;) Currently there's no dedicated engine way of making player pawn follow a path. It seems like a feature we should support in the engine, so we'll add it in not too distant future. In the meantime I'd suggest just having an AI controller on the server that PlayerController would send requests to and have all the movement happen on the server.

avatar image Alex.Holyman Jun 04 '14 at 07:53 AM

Thank you for the clarification. About the AI controller: how do one setup this combination? Is it just the AI controller for the player's character or a combination of the AI- and player controller?

avatar image Furinyx Sep 09 '14 at 07:40 AM

As you stated this in June, I am wondering what the progress is on this? I cannot see it in the UE4 Roadmap and am currently building a commercial Online RPG game with a team which uses the navigation system.

We are currently using a work-around where the server uses an AI controller for the player; however, we would like to have a solution in the next couple of months that allows us to use a networked navigation system with the player controller before we get to a stage where we are ready to release our game publicly (where we plan for an initial release in the next 4 to 6 months). We would prefer not to waste time on re-working the navigation system and implementing this ourselves if it is a planned feature.

avatar image Homer Ramone STAFF Aug 01 '15 at 11:04 AM

Sorry for the delay in replying - this slipped under my radar. Im certainly not an expert on the Navigation side of things but there is a little more info that may help: You can enable client side either navigation by adding the following to the defaultengine.ini in the config folder of your project:

[/Script/Engine.NavigationSystem]

bAllowClientSideNavigation_Experimental=True

This can also be enabled in the project settings.

I was given this explanation from our resident Nav expert Mieszko.

This will result in there being navmesh and the whole of navigation system instantiated on clients as well as on server. This allows for performing pathfinding queries on client, but not much more. Last time I looked at it you can request player-controlled pawn's move along the path, but wit doesn't really work with server. Server knows nothing about this movement type so is constantly correcting client's location to the only known valid location (which is the spawn point).

avatar image spaceharry Aug 01 '15 at 02:09 PM

Thanks for the update! Just tested it.

In 4.8.2 Source and Launcher Preview1 4.9 server doesn't know about movement and corrects location to spawn point as mentioned.

But even if it will work, isn't it better to avoid spawning the Navigation System for better performance on the client? Let's say for example on a mobile phone.

avatar image Alex.Holyman Aug 03 '15 at 09:09 AM

It's interesting that this thread still lives. And I'm glad there is some development in client-side navigation. The main reason for us to use bAllowClientSideNavigation_Experimental would be to predict server movements on the client to reduce the lag. However I'm not sure how one would implement this.

avatar image polygon Aug 03 '15 at 08:48 PM

This is exactly what I'm looking for to reduce the occuring lag. I hope there will be some support on this soon :-/

avatar image wilberolive Dec 14 '16 at 08:25 PM

So, just wondering, after almost 2.5 years has anything changed on this front? I seem to be having the same problem with trying to keep AI pawns in sync while moving. The server moves them, but then the client is constantly correcting them, so they appear jerky.

avatar image chiefGui Feb 06 '18 at 02:40 AM

I'm impressed. After almost 4 years, nothing has evolved regarding this subject? Wow.

Does anyone here found an alternative to @Alex.Holyman's solution? Is there something Epic have prepared for us that I've not found yet?

I'm completely stuck. Simply can't make topdown characters consistently move in the map and replicates that information with precision to the other clients.

avatar image AlcoholV May 08 '18 at 09:27 AM

Please ensure check Allow Client Side Navigation in project settings. pic

move.png (207.4 kB)
avatar image polygon Jul 21 '15 at 07:49 AM

I found this old question yesterday and I'm facing the same problem right now

https://forums.unrealengine.com/showthread.php?77199-Multiplayer-Topdown-Game-Navmesh-won-t-be-replicated-to-clients

It seems that there is still no simple solution implemented by epic and I hope this changes soon :( So are there any news regarding the implementation that Mieszko mentioned above?

And did you guys find a simpler solution for tha client side navigation in the meantime?

(comments are locked)
10|2000 characters needed characters left

Yes

Player movement is properly and wonderfully predicted in the UE4 engine

I know from having hosted multiple real multiplayer games in UE4, some involving more than 2 people!

Rama

more ▼

answered Apr 24 '14 at 07:41 AM

avatar image

Rama
10.5k 444 343 1081

avatar image Crow87 Apr 24 '14 at 02:49 PM

Does this apply to physically driven vehicles/aircraft?

avatar image Osok Dec 01 '15 at 01:16 PM

No it does not. Those are all server side unfortunately.

(comments are locked)
10|2000 characters needed characters left

Can you please post All BPs cause i dont understand how it works at all, and i cant even try to make example cause i dont have all BP sheets

more ▼

answered Oct 07 '16 at 01:24 AM

avatar image

a.pustovitovsky
6 2

(comments are locked)
10|2000 characters needed characters left

This is also causing me bother, an in native engine method would be brilliant.

more ▼

answered Jan 08 '17 at 09:52 PM

avatar image

cptnight00
18 1 7

(comments are locked)
10|2000 characters needed characters left

Hello :)

First of all thank you very much for your help on this! The solution you posted has been fantastic.

I am, however, having problems setting up the proxy. I have posted my question here: https://answers.unrealengine.com/questions/491420/how-do-you-set-up-a-camera-on-a-proxy-pawn-for-a-c.html

If you have the time and notice any reasons why this isn't working, I'd greatly appreciate the help. Alternatively, if you know of any tutorials that could be useful to watch as I try to problem solve - please let me know :)

more ▼

answered Sep 29 '16 at 10:43 AM

avatar image

Amelia_Synapse
3 4 4 6

(comments are locked)
10|2000 characters needed characters left

Hello its 2019 and same problem still exists. for a long time im loking a way to solve this. still couldn't find anything. https://www.youtube.com/watch?v=HqM-XqmqqB4. And just only find this method for the solution. But there is one problem in here. If player has lag and when you try to move it, player waits a little bit. "Wait time depends to your ping" and then it moves.So it can be bad in terms of play. There is nothing like this in "Add Movement Input ". It moves exact time when you try to move.

And i learnt Torchlight Frontiers made with unreal engine.It uses Navigation System click to move and also contains multiplayer.So there must be an another way to make this maybe with c++? or maybe they are using the method that i posted the youtube link.

So could someone manage to make it ? Any ideas ?

more ▼

answered Mar 13 '19 at 03:00 PM

avatar image

sevanberkay
32 4 4 8

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question