0 votes

Hey there,
I have a coordinate where I want to place my Sprite from code. I want it to be centered on the x axis, but not on the y axis.

enter image description here
The rectangle is my sprite, the red cross the coordinate I have.

When using 2D this is easy, I could just get the width of my sprite with

sprite.get_texture().get_width()

and then add it to the x positition devided by 2.

How can I achieve the same thing with a Sprite3D? Using the texture width doesn't work, because the coordinate system isn't in pixels anymore.

So basically for my approach I would need to know how to get the width of my sprite in the metric coordinates.
But I'm grateful for every approach there is.

Thanks in advance!

asked Feb 21, 2018 in Engine by TobiLa (168 points)

Please log in or register to answer this question.

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 How to use this Q&A? before posting your first questions.