How to size a panel based on the current location of the camera

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GiantIsopod
:warning: Old Version Published before Godot 3 was released.

I’m trying to create dialogue boxes for my current project, and I’ve been using a combination of a Panel to act as a base, a RichTextLabel for the words, and a Polygon2D covering the panel as a sort of sprite for the dialogue box, all connected together so that they move as one. (I might later use an actual sprite for the image, but for the moment a colored block is all I need as the stand-in.) I’ve been having success with the code associated with the actual dialogue for my dialogue box, but I can’t figure out how to move the dialogue box around with the camera. So, at the moment I can place the dialogue box at a fixed place on the map, but I can’t figure out how to make the panel fill a specific portion of the current viewport. I drew a terrible picture in Paint to illustrate what I mean.

I will happily accept suggestions on how to do this in the code, in the settings of the node, even alternate methods to the method I am currently doing this. Thank you in advance, I really appreciate the Godot community.

You should probably get rid of the Polygon2D if you don’t need it specifically for some reason. It will make your life a lot simpler if you have to resize the dialog box.

If you want a solid color or even a texture later, the panel is enough.

Select the panel node and scroll down in the inspector to Custom Styles. Add a StyleBoxFlat or StyleBoxTexture to the option named Panel.

aozasori | 2017-08-30 02:20

You’re completely right! Thanks.

GiantIsopod | 2017-08-31 14:27

:bust_in_silhouette: Reply From: aozasori

I’m not sure if this is what you’re looking for, but if you add the dialog box as a child of a CanvasLayer, it will always stay in the same place on screen.

That’s definitely the way to do it, thanks.

GiantIsopod | 2017-08-31 14:33