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. | Twitter

0 votes

I need to get the direction of a 2D object in a Vector2. For example, if it has no rotation, it would be 0.0, 1.0 and if it's rotated 90 degrees (facing to the right), it would be 0.0, 1.0. I am fairly new to Godot, but in I know that Unity has a feature for this called transform.up. Is there a way to do this in Godot? Thanks! :)

Godot version 3.5
in Engine by (14 points)

1 Answer

0 votes

You're probably looking for Vector2.UP

See the CONSTANTS section here.

by (22,674 points)

Thanks, but that doesn’t really help much. I need to get the direction that the object is facing, and I can’t just do getparent().up or Vector2.UP(getparent()). Not really what I’m looking for.

Sorry, I guess I misunderstood the question. Maybe you're looking for one of:

transform.x (for local forward vector) or global_transform.x

Ah, that’s it! Thanks!

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.