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!

in Engine by (205 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 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.