The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I want to make a dialogue bubble which dynamically sizes, so I want to start by checking how close it is to the edge of the screen.

Is there any way to check the x position of the left/right side of the screen? And from there can I do math on it to find the difference in position? I can't find documentation on it anywhere.

Godot version 3.4.2
in Engine by (12 points)

why do you need it? For different screen sizes?

That's one half of it (so that I can reuse it in any game I make) but the second part is I need to tell where the camera is in the world so that I can, y'know, do the math on it to calculate the edges of the screen.

This feature is available for different screen sizes
https://docs.godotengine.org/en/stable/tutorials/gui/size_and_anchors.html
///
But I have no idea for the other problem, sorry. I think it might be more appropriate to find different solutions.

1 Answer

+1 vote

Canvas items have get_viewport_rect() and get_viewport_transform(). For a more general way to get your data you can call get_viewport() from any node and access its properties.

by (1,311 points)

To be fair, most of the time it's quite enough to simply use canvas items' margin features and containers.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.