0 votes

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.

in Engine by (15 points)

1 Answer

+3 votes
Best answer

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()
by (20,475 points)
selected by

thank you very much! that was exactly what I needed

I'm your fan

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.
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 webmaster@godotengine.org with your username.