Multiplayer shared camera

Hello, I am trying to make sense of how cameras are used in UE.

I had a flexible multiplayer set up like the following in Unity and am looking to get as far as possible recreating it.

  • Top down gameplay, all players share the same camera (With tracking similar to Super Smash Brothers)
  • Authoratative networked multiplayer with lobby system, plenty of gameplay options in the lobby.
  • Players had abstracted input, could use either mouse and keyboard or controller
  • Server and clients could have multiple players each, so there could be a client with 3 controller players connected to a server with a controller player and a keyboard player. Obviously, there has to be some seperation between a game process and a player for this to work.

In Unity, I would just add a Camera object to the scene as the main camera and the client would view through it by default, but for UE it looks like each player has their own camera (that follows them in most cases).

I haven’t got any networking up and running yet, but is it possible to set the players view to an external camera that isn’t specific to that player?

I would also be very appreciative of any help pointing me in the right direction for the best angle of approach for the above set up.

I am also confident with C++, but Blueprint seems faster and more appealing to me.

Thanks for any help!

I played around with changing cameras yesterday and it is possible. Place your camera in the level and position it as you like, then in Blueprint, on Event Begin Play, execute a Set View Target with Blend function, set the Target in that function to what Get Player Controller returns, then set New View Target to your other camera. You’ll need to modify your character mesh component to make sure it’s visible.

1 Like

Thanks, that did it! :slight_smile:

Hi, I did all what is said in the best answer by Zero One, but it just seems to work on the server preview, on the client preview things gone without changes. I cant visualize level camera in the client preview using Set View Target with Blend function, maybe is problem of the Player Controller that Im passing to the function… Some help will be awesome! Thanks.

I’m having the same issue over here. In a multiplayer environment, SetViewTarget() on the clients don’t seem to do anything.

My project is in C++, but hopefully the solution is similar in blueprint.

Be sure to set

bAutoManageActiveCameraTarget = false;

in your PlayerController constructor. And then be sure to use

ClientSetViewTarget()

and not

SetViewTarget()

After disabling active camera management (above), my project crashes if you use SetViewTarget, in which I assume is because SetViewTarget doesn’t set a camera on the client in a multiplayer environment, therefore leaving the client with no camera to use which leads to a crash? I could be completely wrong, though.

I’m also calling ClientSetViewTarget() in the PlayerController BeginPlay() event handler, for those who may be curious.

1 Like

Hi,
I did what Zero One suggested in BP. The problems are:

  1. You are looking throw a static camera. Doesn’t follow the player.
  2. The player can still run out of the frame so technically it’s not a player veiwport.
    The question remains. How do we setup a multiplayer camera in a non-splitscreen camera?

Many thanks

Did you ever get this to work? I’m trying to do the same thing. Shared top/down board for all players connected.

What worked for me was to set bAutoManageActiveCameraTarget = false; in the player controller class

Note that ClientSetViewTarget() is not exposed to BP by default (UE 5.0.1).

I bumped into this post, looking for a way to bind multiple clients to a single camera with Blueprint only. The post currently seems to end on a somewhat sour note (“ClientSetViewTarget() is not exposed to BP by default (UE 5.0.1)”), so I wanted to add a little more info since I was able to get this working in a pure BP solution.

It took some figuring out, but there may be an even better way to do this - I’ve only been working in UE during my free time for a few months now:

QUICK NOTE: a Custom Controller is necessary, but a Custom Camera is technically not… I use a custom camera “Map Camera” here because it helps cut down on some adjustments I expect to reuse across levels.

Step 1: configure your camera: whether it’s a custom camera or not, you’ll want to ensure that Auto Activate for Player is set to “Player 0”. Disabling this option resulted in the camera never setting up for any of the clients or even the host (if running as Listen Server).

Unfortunately, I think setting the auto-activate option for Player 0 means I’m benefitting from a race condition here… which makes me uncomfortable, but it does work consistently for me so far. Until I find a better way to delay camera attachment, this is my go-to strategy for now.

Step 2: create a simple setup function within your custom “Player Controller” (which we will call soon):

Step 3: Add event “Handle Starting New Player” within your custom “Game Mode” class:

Bonus: Even though these steps seem to work well for cameras, they do not work well for attaching widgets to each player’s HUD. For that, you’d need to consider setting up some RPC calls. I have some firing off via server/client events… which was a good learning experience but I also feel that there’s likely a better approach I’m not seeing quite yet.