mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Bad tank movement
This commit is contained in:
parent
12f0062fe8
commit
90d2a95fa8
10 changed files with 514 additions and 8 deletions
|
|
@ -77,4 +77,16 @@ public static class Tools
|
|||
{
|
||||
return node.GetNodeOrNull<InventoryManager>("/root/GameScene/InventoryManager");
|
||||
}
|
||||
|
||||
public static Vector2 GetSnappedDirection(Vector2 direction)
|
||||
{
|
||||
// Snap to one of 8 directions
|
||||
var angles = new[]
|
||||
{
|
||||
Vector2.Up, Vector2.Up + Vector2.Right, Vector2.Right, Vector2.Right + Vector2.Down,
|
||||
Vector2.Down, Vector2.Down + Vector2.Left, Vector2.Left, Vector2.Left + Vector2.Up
|
||||
};
|
||||
|
||||
return angles[Mathf.PosMod((int)(direction.X + 4), 8)].Normalized();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue