Culling mask in Camera2d

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nineGradens

Hey everybody.

So… I’m making a 2d platformer, and was hoping to give the player a “Camera” in game. I want them to take have a printscreen option but I DON’T want the printscreen to include the players HUD.

So… I was planning to have an extra camera floating around, and make the HUD invisible to that camera- either by having it ignore the UI canvas layer, and culling mask…
But Camera 2d doesn’t appear to have those things.
Is there something I’m missing?

If not, is there a way to make the UI invisible, force the camera to update, save the image to file and then make things visible again BETWEEN camera frames (so as not to disturb the player view?)

:bust_in_silhouette: Reply From: Zylann

I don’t think it’s possible to avoid flickering without a viewport, currently.

Without viewports, you really have to hide the HUD, let one frame pass, take that screenshot and reenable the HUD.

With viewports, you would have to rearchitecture your node hierarchy so that the game world is under a Viewport node, and the HUD drawn outside of it. This allows to access the result render of the game without the HUD in it.

Another option is to have an actual hotkey in your game to hide the HUD, which is a common workaround in some games (like Minecraft or Robocraft).