Creating Camera For Multiplayer From Blueprint on Player BeginPlay

Hello All,

I am working on a simple multiplayer side scroller platform game in Unreal 5.

When starting the project I made the player so that it had a spring arm and camera component with Absolute Rotation and having the camera set to Ortho. The players are spawned in by the Player Start and automatically have their own camera.

I have tested in listener server (editor) for how this behaves on clients and all seems fine but now that the project is on a remote server (dedicated) it almost seems like the camera cannot keep up with the player during custom movement events which include launch the character (Event is being fired on client first and then also on server, no prediction, not believed to be rubberbanding) – this results in a very jittery camera experience that sometimes seems like the entire level is shaking for the client in control.

Since this is a multiplayer game simply enabling camera lag on the spring arm for some smooth camera movements isn’t working (whenever I do this it is noticeably MORE jittery during launch events). I believe this is a known issue.

My solution was to creat a custom camera blueprint based on Mathew Wadstein Camera with Deadzone video on youtube and then I am creating the object, spawning it and assigning it to follow the player all within the players BeginPlay event. Here is what that event looks like:

On the Camera, there is a Tick Event that looks like this:

This all seems to work fine in standalone, but as soon as I open it in client on listen server I can see that the Camera is only created / following the servers character. The client gets a seemingly first person style camera which has the wrong rotation – like a default camera?

I have also tried setting the event to Run on Owning Client with an Authority Switch as seen here:

Using the above only prevents the camera from working on the server. It doesn’t fix the issue with the client. If anyone can explain to me why only the server is generating a proper camera please let me know. I am open to any suggestions and happy to supply more information if needed.

I added a Print String into the tick event of the Camera BP which shows which actor the Camera is set to follow and I can see that the Event Tick is only running for the player on the server. I don’t think handling Camera should take any type of replication since each client should control their own Camera. I’m not sure why the Server is the only one creating the Camera BP.

I’ve had issues similar to this on a dedicated server and with cameras, but I’m not sure if they are related to your issue. The things I found out were that you cannot move a camera if “UsePawnControlRotation” is on. It must be marked false right before moving the camera and then set it to true right after (I’m not sure if you’re even using pawn control rotation), but it wouldn’t hurt to check… That first person camera you’re talking about sounds like the default player controller camera because if its not a component or added at the right time it’ll just revert to that camera.

I had replication issues on movement after doing leaps and bounds of programming for replication that worked perfectly in pie, standalone game and everything else. But on the packaged dedicated server, it turns out movement is NOT replicated like it is on a lan connection or local machine running multiplayer. I had to force replication on the movements or the character simply wouldn’t move. Another thing I ran into was waiting to send server commands because latency would cause late connections into the game mode despite server travel and everything else and I guess functions miss the boat so to speak and never get called because the player hadn’t totally initialized before they were issued. Again, might not even be your issue, but sounds like what might be happening when you see that first person view…

Have you considered adding the camera and spring arm as a component and just moving the spring arm or camera on begin play? You can set up multiple cameras with different transforms and just set them active or not and move them all over the place without using set view target with blend. If you need collision on the camera to avoid obstacles you’ll need to only move the spring arm or the collision will be janky.

I’ll have to look into the UsePawnControlRotation next time I try this. It looks like the camera that spawns on the server works like a charm, it is only client side camera that is not connecting to the player.

if I put print string in the constructor for the Camera BP I can see that 2 are being created. It is like the setViewTargetWithBlend is only being called for the servers player.

@Humanasset What do you mean when you say you’ve had to force replication?
I understand that certain custom movements may required movement prediction in order to execute. I can’t be certain that’s what I need here but my movement events seem very straight forward, also this would requires some C++ knowledge to which I don’t entirely feel confident.

There is a chance that my jitters could be network related but even still I feel that this blueprint to spawn the camera seems correct.

I quickly solved it by just running a custom event set to “run on server” calling a custom event with my movement logic set to “Multicast” I fed the axis values in as a parameter to the multicast and into the server event from the movement input if that makes sense. I’d leave these unreliable and tune down your net update frequency until its just smooth enough. You can replicate variables and set them, but it gets really complicated I’m still working on optimizing that. I also had to make the same exact logic on another custom event set to “Run On Owning Client” for the client’s side.

If you haven’t already, check your editor preferences and turn off network emulation. If that’s on at all it’ll jitter like crazy all the time. They should call it “Add Lots of Jitter” with a little tick box lol.