How can I create a multiple-camera/multiple-monitor Setup?

Hi guys,

So I am currently looking into a feature that’s required for a project, specifically, I have three separate cameras setup in my Player blueprint, and I need all three of them to render to separate views. Each of these views will be fit on a separate monitor, or projected by three separate projectors, based off client requirements.

I have been able to setup my character with three cameras (which honestly is the easiest part of the deal), but where I’m getting stuck is creating three different viewports for these three separate cameras. I tried looking into a previous thread and tried to make some sense of it, but honestly, I find it slightly cryptic:

https://answers.unrealengine.com/questions/30918/does-ue4-support-multiple-monitors.html

More specifically, I am alluding to the section where Mike is talking about the UGameEngine::Init() and the CreateGameWindow and CreateGameViewport methods.

Hunting around a bit more, I found the wiki page for how to override the UGameEngine module:

https://wiki.unrealengine.com/Create_Custom_engine_classes_for_your_game_module#Extending_the_editor_engine

Following the methods described here, I have been able to successfully subclass the UGameEngine class into my own class called CTGameEngine. And that’s about all that I’ve been able to do.

I tried setting up my own viewport, but I always end up with an exception. Here’s the offending code:

void UCTGameEngine::Init(IEngineLoop * InEngineLoop)
{
	DECLARE_SCOPE_CYCLE_COUNTER(TEXT("UGameEngine Init"), STAT_GameEngineStartup, STATGROUP_LoadTime);

	// Call base.
	UGameEngine::Init(InEngineLoop);
	// Creates the initial world context. For GameEngine, this should be the only WorldContext that ever gets created.
	FWorldContext &InitialWorldContext = CreateNewWorldContext(EWorldType::Game);
	
	// Initialize the viewport client.
	UGameViewportClient* ViewportClient2 = NULL;
	if (GIsClient)
	{
		ViewportClient2 = ConstructObject<UGameViewportClient>(GameViewportClientClass, this);
		ViewportClient2->SetReferenceToWorldContext(InitialWorldContext);
		GameViewport = ViewportClient2;
		InitialWorldContext.GameViewport = ViewportClient2;

		SecondaryViewportClients.Add(ViewportClient2);
	}
	
	if (ViewportClient2)
	{
		ViewportClient2->AddToRoot();
		ViewportClient2->LayoutPlayers();
		//ViewportClient2->SetViewport();
		CreateGameViewport(ViewportClient2);
	}
	bIsInitialized = true;

}

This is almost a straight lift from the UGameEngine::Init() documentation.

When I tried to debug it, I found that my ViewportClient2 was a NULL pointer, even though it was actually going through all the steps of creating the ConstructObject, etc.

So, any pointers (pun not intended) on what I may be doing wrong here? And what I should be trying to do instead (other than asking someone else to look into coding this thing, that is not an option)?

So does anyone have any insights?

Bumping this up…

UGameEngine::Init() calls

FString Error;
if(!ViewportClient->Init(Error))
{
	UE_LOG(LogEngine, Fatal,TEXT("%s"),*Error);
}

You seem to be missing the Init call to your new ViewportClient

Hi, Were you able to configure more than one Portview on their monitors?

There is the possibility of posting as was your code? need to do the same for 2 monitors …

Hi, Were you able to configure more than one Portview on their monitors?

There is the possibility of posting as was your code? need to do the same for 2 monitors …

Hello friend, I need to do the same thing as you … How did you solve this problem … you could post your code here …

Have you solved this issue with the information of TheBabelFish? Because i need somethin similiar too.

if this is still a question to you , you should might have a look into here :

This link goes to a “maintenance mode” screen…

Thats not my fault the whole unreal engine forum is down due to maintenance since yesterday. Be a little patient or just ask me a more detailed question.

I will try to help you solve your problem

Best Regards

Thank you for your quick response,

I would like to have your advice.

I’m doing a video mapping project and need to take out each in-game camera to each projector.

I found this for rendering two windows : GitHub - chaosgrid/ExtraCamWindow: A simple Unreal Engine 4 plugin that allows to have extra game windows with their own camera viewpoints.
I’ve tried it, it has some glitches but I can see how it’s done.

There is also this tread that explains how to chose the default monitor : https://www.reddit.com/r/unrealengine/comments/3j7bo4/is_it_possible_to_choose_the_default_screen_in_a/
It may be a best solution but I was wondering if you have access to in-game cameras in the engine class…

Other solution would be using split screen and extend (easiest method).

I’m wandering if it wouldn’t be a best solution to use an external video-mapping software because the screen is not flat so I would need to do some wrapping, one camera renders the 3D scene that is put onto the uv of the wrapped plane to fit with the screen (I would have to do a tool like this : Projection Mapping Tutorial - Resolume Arena 4 - YouTube). This plane is rendered by two other cameras that represent each real projector.
In this case I would have to find a way to send unreal game output to the mapping software, I guess it’s possible.

What would be your advice ?

Finally I’m going to use a video-mapping soft. I found how to link UE4 and Resolume with Spout plugin and it looks very easy.

Thank you for your time !

Did you complete?