diff options
author | kobewi <kobewi4e@gmail.com> | 2021-04-27 15:53:04 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2021-08-31 01:53:58 +0200 |
commit | 3f3739ccb56fdadab79e17e6a5865381e0821228 (patch) | |
tree | 23fce9717b71c7efd76640d71642c744cc273bd0 /modules/mono/glue | |
parent | d085b2d04d6a6f972cc252532dbbf07f0d54fc3c (diff) |
Add Vector2.from_angle() method
Diffstat (limited to 'modules/mono/glue')
-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; |