Something like transform.up from Unity

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CodeOrange

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! :slight_smile:

:bust_in_silhouette: Reply From: jgodfrey

You’re probably looking for Vector2.UP

See the CONSTANTS section here.

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 get_parent().up or Vector2.UP(get_parent()). Not really what I’m looking for.

CodeOrange | 2022-09-21 21:13

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

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

jgodfrey | 2022-09-21 21:33

Ah, that’s it! Thanks!

CodeOrange | 2022-09-21 21:42