I’m making a first-person game, and I want the player to look through a security camera to take a screenshot to use later. How can I swap the cameras? I tried doing it with a Set Active with New Active checked blueprint node, but it didn’t work.
Swapping cameras is not the tool for this. Set Active changes what the player sees, but you do not want to see through the security camera, you want an image from it. For that you want a Scene Capture Component 2D writing into a Render Target, and the player’s own camera never has to move.
Put a SceneCapture2D on the security camera actor, create a Render Target asset, and assign it to the capture’s Texture Target. From then on that render target holds whatever the capture sees, and you can show it on a widget, put it on a material, or read the pixels out and save them.
Four settings decide whether this works or looks wrong.
Capture Source: set it to Final Color (LDR). The scene colour options hand you an untonemapped buffer that looks nothing like the game. This is the one that catches people out.
Capture Every Frame and Capture On Movement: turn both off. Left on, you are rendering the scene a second time every frame for a shot you take once. Call Capture Scene when the player presses the button instead.
Hidden Actors: add the player pawn if it can get between the camera and what you are shooting.
For a still you keep rather than a live feed, call Capture Scene once and then read the render target. In Blueprint that is Export Render Target to write a file, or Read Render Target Pixel if you only need colours. In C++ it is GameThread_GetRenderTargetResource then ReadPixels, and with Final Color LDR you want the default read flags with no gamma conversion, since the image is already tone mapped and in gamma space.
Worth knowing before you scale it up: a scene capture is a full extra render of the scene. One on demand is cheap. Several running every frame is not.