Bad tank movement

This commit is contained in:
Marco 2025-02-18 17:40:33 +01:00
commit 90d2a95fa8
10 changed files with 514 additions and 8 deletions

View file

@ -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();
}
}