Simplify code for retrieving direction vectors

This commit is contained in:
Yuri Roubinski
2023-09-12 09:36:40 +03:00
parent 8e69f6be0c
commit 8377137565
6 changed files with 12 additions and 31 deletions

View File

@@ -178,7 +178,7 @@ degrees to either side:
.. code-tab:: gdscript GDScript
# Calculate vector from `a` to `b`.
var dvec = (point_b - point_a).normalized()
var dvec = point_a.direction_to(point_b)
# Rotate 90 degrees.
var normal = Vector2(dvec.y, -dvec.x)
# Alternatively (depending the desired side of the normal):
@@ -187,7 +187,7 @@ degrees to either side:
.. code-tab:: csharp
// Calculate vector from `a` to `b`.
var dvec = (pointB - pointA).Normalized();
var dvec = pointA.DirectionTo(pointB);
// Rotate 90 degrees.
var normal = new Vector2(dvec.y, -dvec.x);
// Alternatively (depending the desired side of the normal):