how to get a numeric value of a Vector2( )

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

hello, I’m working on the “enemy” code using an Area2d and I would like to know how I could transform the value of a Vector2 () into a number so that it can be assigned in the rotation property? … or if there is a specific method for this will also be of great help.

:bust_in_silhouette: Reply From: kidscancode

I think you mean you want to find the angle of a vector, which is what you would need to put in the rotation. You can get that with vector.angle(). For example, if you have a velocity vector for your movement, you could rotate to match that vector’s angle with

rotation = velocity.angle()

thank you very much! that was exactly what I needed

I’m your fan

MaxDeveloper | 2020-07-01 01:12