summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorChaosus <chaosus89@gmail.com>2019-03-27 13:51:05 +0300
committerChaosus <chaosus89@gmail.com>2019-04-05 17:09:57 +0300
commit55f3bd97a270b691c26d6eda70bc7c0a3ec8f4e8 (patch)
tree2026f7241b7e7670ffb97ceff22962ce90b432f7 /modules
parent6574c557c962d9e4dd726b494322aea246a0245a (diff)
Added direction_to method to vectors
Diffstat (limited to 'modules')
-rw-r--r--modules/mono/glue/Managed/Files/Vector2.cs5
-rw-r--r--modules/mono/glue/Managed/Files/Vector3.cs5
2 files changed, 10 insertions, 0 deletions
diff --git a/modules/mono/glue/Managed/Files/Vector2.cs b/modules/mono/glue/Managed/Files/Vector2.cs
index 73a3252fdb..908162ec45 100644
--- a/modules/mono/glue/Managed/Files/Vector2.cs
+++ b/modules/mono/glue/Managed/Files/Vector2.cs
@@ -132,6 +132,11 @@ namespace Godot
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
}
+ public Vector2 DirectionTo(Vector2 b)
+ {
+ return new Vector2(b.x - x, b.y - y).Normalized();
+ }
+
public real_t DistanceSquaredTo(Vector2 to)
{
return (x - to.x) * (x - to.x) + (y - to.y) * (y - to.y);
diff --git a/modules/mono/glue/Managed/Files/Vector3.cs b/modules/mono/glue/Managed/Files/Vector3.cs
index f6ff27989d..0c96d346a9 100644
--- a/modules/mono/glue/Managed/Files/Vector3.cs
+++ b/modules/mono/glue/Managed/Files/Vector3.cs
@@ -126,6 +126,11 @@ namespace Godot
);
}
+ public Vector3 DirectionTo(Vector3 b)
+ {
+ return new Vector3(b.x - x, b.y - y, b.z - z).Normalized();
+ }
+
public real_t DistanceSquaredTo(Vector3 b)
{
return (b - this).LengthSquared();