# First person spectator camera

Hi,

I’m doing a project for school, and I am struggling with blueprints.
What I want to achieve with networking is, while someone is playing a FPS character as the server, every client which are connecting to the server spawn as a first person spectator camera seeing what the server player is doing.

I would use this setup for a VR Showcase, in order to allow the audience to see what the VR player is doing in game.

I guess it’s easily doable but I’m a noob with BPs, and I could not figure it out. Even after reading the documentation and exploring First Person Shooter example and UT BPs.

Some assistance would be greatly appreciated !

It’s fairly straightforward actually. Give me some time untl i return to my pc and I’ll post you a proper answer with intructions.

Thanks !
It would be really helpful.

Ok, the best way I think would be to start all players with spectator pawns and let the server one switch to a playable character later on. It is also possible to set up spectator/player classes properly as in a regular competitive FPS, but no need for it right now.

Start with the Default Pawn (it comes with the engine and is set by default if you ) set as your character in the Game Mode. Then spawn a playable character from the server blueprint (you can put a has authority switch to check if it’s indeed the server) and get your player controller to possess it.

Back again

So I did what you suggested, and indeed it works fine. Everyone connecting to the game spawn as a spectator and only the host can possess the character pawn.

Now I struggle with the first person camera thing.
I tried to create an camera actor, and then to attach it to my playable character pawn. Obviously it’s tied to the mesh and not the actual camera of the character pawn.

So far I was unable to replicate the camera view of my playable character pawn to the other camera actor.
Any idea?

As long as the playable pawn character has a camera, possessing it would automatically activate its camera and deactivate others actually.

I think I have not explained the situation well enough.
It’s a two players showcase :

1. One player is the host, and will take
control of the playable character
pawn (with the oculus rift)
2. The other player is a spectator, always. He starts as a default spectator pawn, but I want him to be able to see the playable character pawn point of view. To be honest, the point is to record this second view on another computer without impacting the first player (the oculus rift is very needy in ressources).

I don’t know why what seems a really basic feature of every multiplayer game seems so hard to achieve, I guess I’m not familiar enough with the BPs. But to be honest, I litteraly lost half a day toying with BPs with little results.

Curious - did you ever solve this problem? I’m looking at something similar and would love to hear how you resolved.

Not really.

I was able to “stitch” the camera to the player someway but I could not figure out how to make it follow the view of the player.
The camera was linked to the head of my character but it did no’t take into account head movements. Time was going on and I just gave up to be honest.

I have the feeling that you can adapt the C++ code from Unreal Tournament multiplayer to achieve this. I looked into the code at the time (a few months ago) and it seems it requires some deep editing in order to transpose a working spectator camera to another project.

Maybe it’s easier nowadays since I work on other projects right now and don’t really have time to toy with the new UE releases.
If you find a way somehow, it would be nice to post it here.

Hey,

I needed similar thing and managed to find a solution.

It turns out, that UE4 has spectator functionality built-in. It’s just not properly documented and advertised.

There’s a set of functions that allows you to cycle through players if you are curently spectating.

I’m attaching the project that has this figured out. I’ve tried it on GearVR and PC. GearVR was acting as a server (so that spectating functionality is optional).

By default the game loads an entry map, that immediately chainloads another map but with ?listen parameter to make sure that the game starts as a listen server.

Next, you can connect from PC with another instance of the game:

cd C:\Program Files\Epic Games\4.10\Engine\Binaries\Win64
UE4Editor.exe C:\Path\to\project\NetTest.uproject 10.0.0.5?SpectatorOnly=1 -game


Replace path and ip accordingly. The SpectatorOnly=1 causes the player to immediately become a spectator (Look at AGameMode::Login()).

After you connect, press PageUp and PageDown to cycle through players, and Home to go back to free
flight camera (in this example it’s quite limited becuase it’s set up for mobile controls).

Relevant logic (not much of it) is implemented in Content\FirstPersonBP\Blueprints\Spectator asset and in
ANetTestPlayerController class.

Effectively, spectator functionality is implemeted as changing the view target in PlayerController/PlayerCameraManager ( APlayerController::SetViewTarget() ).

If you have more questions, feel free to ask.