+2 votes

Basically I want to use an angle degrees float value that I got from the angle between two points in order to move a kinematic body with the move() function.

The Move function however takes a Vector2(x,y) value for the direction of movement

What I want to ask is - how the hell do I turn my angle degrees float value to a Vector2(x,y) value to be used by the move function?

in Engine by (100 points)

1 Answer

+4 votes
Best answer

You can get the direction vector by subtracting the second point from the first. You can then normalize the vector and multiply it by your speed (and delta assuming you're doing this in fixedprocess).

var direction = ( target.get_pos() - self.get_pos() ).normalized()

by (1,330 points)
selected by

That did it! Thank you!

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.