Help with keeping pause menu in viewport

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

Hey all, I’m trying to add a pause menu to my game but I’m running into the problem where the pause menu is fixed to the initial viewport area and doesn’t move as the player moves. My current scene layout is roughly as follows:

  • Game (Node)
    • World (Node2D)
      • Tilemaps
      • Player (KinematicBody2D)
    • PauseMenu (Control)

The issue of course is that when the player moves beyond the bounds of the viewport in the world, the pause menu does not follow the current viewport and so I don’t get the menu to pop up unless the player moves back to the starting viewport area.

What’s the best way of structuring this so that I can keep everything uncoupled and don’t have to resort to e.g. attaching the pause menu to the player’s camera or something? I imagine there must be a way of specifying that something always be anchored to the viewport, so to speak. I could also see something like that being useful if I wanted to e.g. apply a shader to the entire viewport.

Thanks in advance for the help!

:bust_in_silhouette: Reply From: sparkart

Use a CanvasLayer.

Brilliant, so simple. Thanks a lot!

AUD_FOR_IUV | 2019-06-08 18:18