This particular code snippet is a bit tricky to underestand for me!!

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

var thrust = Vector(0,50)

  1. how does rotated work internally, I just want to know how it works in godot.

if possible i would like to also know the formula used to generate the rotation of the Vector.rotated(1);

:bust_in_silhouette: Reply From: jgodfrey

So, I assume that thrust is a Vector2 object? Though, if that’s the case, that first line should have Vector2(0,50), not Vector(0,50)

Anyway, assuming it’s a Vector2, then the call to .rotated is a method on the Vector2 object. So, you can see its docs by looking at the Vector2 object and finding the rotated method, here:

There, you will see that the method rotates the vector by the specified number of radians.

So, your code will take the original vector (50,0) and rotate it by 1 radian. That results in a new Vector2, which is then passed into the set_applied_force call.