For a game that I am getting started making I have had to learn vector math to calculate forces. To convert a vector from x and y to magnitude and angle I have read that I for the angle have to use the function tan^-1(y/x). Is this correct and if so how do I implement it into godots GDscript?
For a game that I am getting started making I have had to learn vector math to calculate forces.
First, this isn't necessarily true. Depending on your use case, it may be most effective to use Rigid Bodies and let Godot compute the effects of forces for you.
To convert a vector from x and y to magnitude and angle I have read that I for the angle have to use the function tan^-1(y/x).
To convert a vector from x and y to magnitude and angle, use Vector2.length()
and Vector2.angle()
.
That being said, if you want to learn vector math, do it! Godot has its own vector math docs, and I'm sure you can find plenty of other similar lessons online. However, it is good to be aware that the engine provides much of this functionality for you. Writing a bunch of vector math instead of just calling a bultin function will just make your code more complicated.