mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
Simplify code for retrieving direction vectors
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user