|Topic was automatically imported from the old Question2Answer platform.
I’m new to Godot.
I would like to get the width and height of a node in pixels using code but I can’t find a way to get this property. I was searching the forum, the docs and the web and seems like everyone mentioning how to get scale but I don’t need the scale (1:1) value.
I need the actual width and height in pixels of a Sprite or a Node2D node but I can’t figure out how to get it.
I would appreciate any help.
A Node2D does not have a size, it only represents a position/rotation/scale (ie transform), and does not have any visual representation.
To get the size of a Sprite, you look at its
var size = texture.get_size()
Thanks a lot. It worked
ddabrahim | 2019-01-13 22:15
if it worked, would you select the answer please? so others looking for the same answer can reach the solution easily!
It returns the actual size of the image, but not the size at which it is displayed in case it’s scaled. How could we get that information also?
If you use get_size() you can multiply that by the scale to get the current scaled size of the sprite
MrBundles | 2021-07-13 03:05