diff options
author | George Marques <george@gmarqu.es> | 2021-09-01 09:32:42 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 09:32:42 -0300 |
commit | cf59028972e013128703033bc2ef1677098138bf (patch) | |
tree | 55c06ac3be2230483b41eb349e8916dafaa975b7 /modules/mono/glue/GodotSharp | |
parent | ac7541c1b1f435587afb1d7b74129c813a1c84dc (diff) | |
parent | 3f3739ccb56fdadab79e17e6a5865381e0821228 (diff) |
Merge pull request #48237 from KoBeWi/they_came_from_angle
Add Vector2.from_angle() method
Diffstat (limited to 'modules/mono/glue/GodotSharp')
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index 8bb5e90a68..b4c4ddabb9 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -603,6 +603,17 @@ namespace Godot y = v.y; } + /// <summary> + /// Creates a unit Vector2 rotated to the given angle. This is equivalent to doing + /// `Vector2(Mathf.Cos(angle), Mathf.Sin(angle))` or `Vector2.Right.Rotated(angle)`. + /// </summary> + /// <param name="angle">Angle of the vector, in radians.</param> + /// <returns>The resulting vector.</returns> + public static Vector2 FromAngle(real_t angle) + { + return new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)); + } + public static Vector2 operator +(Vector2 left, Vector2 right) { left.x += right.x; |