I have a player pawn that acts as a camera for the client. I then spawn a player character on the server and possess it with a AI controller on the server. A player controller on the client side takes input and sends a location to the AI controller which then moves the character on the server. The problem is that the net cull is deleting the character assigned to the player even though the camera is following it unless I set the character as always relevant.
bAlwaysRelevant = true fixes the problem? This will always replicate the character on all clients so it might be an overkill.
What is the character’s network role? Simulated, Autonomous or Authority?
What is your
AActor::NetCullDistanceSquared and can you increase it?
What is your player pawn? Your player obviously does not possess the character but why?
If I set always relevant or increase the netcull distance it does fix it but I don’t want to have them set. The player pawn is just an empty pawn with a camera. I cannot use an AI controller to move my character when I click because I need a normal controller to take input. So my player controller has to tell the AI to move the character instead.
Ok. So your game is some kind of strategy…
When you move your pawn closer to the unit does it appear again?
My suggestion is to move your player pawn with your camera so it always remains in the center of the screen. (I suspect you already do this)
Set your netcull distance to encapsulate all characters that can be on your screen (depending on zoom) + maximum unit range so you can visualize the effects of a unit shooting from outside the screen.
I have the camera attached to the pawn that updates its position on tick. Shouldn’t the camera move with it already? The net cull seems to be calculating from the world origin where I spawn everything.
The problem was that I was updating the camera only on the client.
Could you explain more? I’m having the same issue and I can’t think of anywhere that I’m updating the camera. What does this mean exactly?
Ok, I hacked it somehow. Seems that running the Movement Component’s Add Input Vector on the owner/multicast will tell Unreal that the actor location has updated.
So I added an Add Input Vector node just after my multicast replication(should work on run on Owner too).
This node simply takes the GetActorForwardVector x 0.000001 to get the smallest vector, so that Unreal still updates the location, but we don’t actually affect gameplay that much.