Multiplayer set camera position at startup

I’m trying to get a players view target to a camera that looks over the world at startup and can’t get it to work for network clients.

I have tried a variety of methods from putting the SetViewTargetWithBlend function into the character BP, the game mode BP and with run on client/server/multicast etc. The only camera that works is on the client that is the server as well. All others seem to briefly switch the camera - and the code does get to the SetViewTarget node - but then the camera ends up on the player.

The only way I’ve managed to get anything to work is to set a timed event to switch the camera, but this only works so long as the timer is after whatever system is jumping in and setting the camera back to the players camera.

Is there some setting that I can use to tell the system to not use the camera attached to the actor? Or is there some other event that I need to use that happens after the system decides to wire up the camera?

All assistance greatly appreciated.

1 Like

Unfortunately this is one of the first things I thought might solve the problem. It seems like the creation/possession of the pawn is happening at some later time. I see a brief flicker of the camera being in the right position before it then moves to its spawn location.

Here’s the BP I’ve tried to use which follows what you’ve suggested. I’ve tried various renditions of it from all of the replication options, to looping through all of the game players and trying to set them all. No matter what I do, the client on the server works and the rest reset to the camera attached to the player.

Try initializing it on the client from the server. You can do that by creating a Server Replicated Event on the Player Pawn. It will be executed by the server when the Pawn calls Event Possessed (Which only happens on the server once.) Then the server will tell the client PC to find the camera that is looking over the world and set view target with blend.

You seem to understand well enough, so if you need more details I can explain further.

Ok, seems like I have found a workable solution to this and something that may be involved. Turns out that the player controller I’m using is derived from a class that’s overriding APlayerController, although I don’t see anything in that class that would directly cause this problem.

In the player controller class defaults, disabling the setting ‘Auto Manage Active Camera Target’ has given me control.

1 Like

That’s actually not what I suggested but I’m glad you were able to figure it out!

Yeah I know and thanks. I had tried what you suggested as well, along with many other options, but from what I’ve observed it seems to be something related to the timing or order of setup - though it appears to be more likely timing. Without knowing the underlying code I wouldn’t want to assume anything.

However, I’ve since read up quite a lot on how I should have been dealing with server/client functionality and have moved most of my code out of the character class and into a player controller and am pushing the world logic up into the game mode class. Things are starting to get a lot better thanks to that.

Cheers

Same is happening to me. How do I edit my player controller class defaults?

I think you’ll need to create a new BP from the PlayerController class and edit it there, then set your game mode to use your new controller. Sorry I can’t be more specific, because I’m not on a PC with UE right now.