Bind a camera actor to a monitor? (3 cameras, each for a monitor)

I have three monitors, and I have three camera actors in the game. I want to have each monitor display one of the cameras, respectively.

I already know how to get the information (id, name, resolution, etc.) about the monitors, thanks to this post FDisplayMetrics::GetDisplayMetrics | Unreal Engine Documentation

My question: Given the monitor id (or name) and the reference to a camera actor, how do I make the camera’s scene displayed on that monitor? Do I need to have three SWindow objects?


I know a workaround: Run three game instances, each one for a camera. This is easy. Then, I use the following code to make each of them shown on corresponding monitor: Reference: (in Chinese)

#include "Misc/CommandLine.h"

void AMyActor::AA()
    // Move window to the corresponding monitor
    if (GEngine && GEngine->GameViewport) {

        int MonitorNumber = 1;
        FParse::Value(FCommandLine::Get(), L"monitor=", MonitorNumber);

        FDisplayMetrics Display;

        int8 MonitorIndex = MonitorNumber - 1;
        int32 CurrentMonitorWidth = Display.MonitorInfo[MonitorIndex].NativeWidth;
        float WidthPosition = (MonitorIndex)*Display.PrimaryDisplayWidth - CurrentMonitorWidth;
        float HeightPosition = 0.0f;

        FVector2D WindowPosition = FVector2D((-1)*WidthPosition, HeightPosition);

Finally, add the ApplicationCore module in Build.cs file, so that the linker knows where to find the library used above.

1 Like