How can I make two players share a camera in code?

Hi!

I want to create two players that shares a camera? How can I achieve this in code?

You can set same view target in both players controllers

Thanks! I will try this.

It worked fine except the camera is viewed in splitscreen mode and I actually wanted only one camera for the whole screen. I see the question is a bit ambiguous about this. Do you know how to achieve that?

Set this to none i guess if it wont work search viewport classes
https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UGameViewportClient/Default2PSplitType/index.html
Edit: i think this will be better, set this to none
https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UGameViewportClient/SetSplitscreenConfiguration/index.html

I have tried this without any success. I can’t find any other function or property that seems to make sense to call or set in UGameViewportClient related to the splitscreen problem. I also want to make sure only one camera is rendered and only once per frame.

I use GEngine->GameViewport->SetSplitscreenConfiguration(eSST_NONE); in my GameMode’s PostInitializeComponents() method.

how do you access instance of that class?

hmmm there possibility that you set is being overwritten later on, maybe try to st splitsceen configuration first and then set up 2nd player. Try diffrent events too

I’m posting what I answered here: How can I get all Actors on the Screen drawn by a SceneCaptureComponent? - Cinematics & Media - Epic Developer Community Forums

You should make a subclass of GameViewportClient and don’t forget to tell the engine to use the subclass (set it inside Project Settings in Unreal Editor).

In the .h file add something like this:

	virtual void UpdateActiveSplitscreenType() OVERRIDE;

And in the .cpp:

void UMyGameViewportClient::UpdateActiveSplitscreenType()
{
	ActiveSplitscreenType = eSST_NONE;
}