From 555982262f5629845e2627d0ab2cba1abd0a7879 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sun, 21 May 2023 17:29:44 +0200 Subject: [PATCH] Properly place entities at their corresponding heights. --- scenes/Game.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scenes/Game.cs b/scenes/Game.cs index a823013..2b069a8 100644 --- a/scenes/Game.cs +++ b/scenes/Game.cs @@ -252,6 +252,16 @@ public class Game : Spatial _player.Transform = playerStartTransform; _player.TaskQueueComponent.Reset(); _player.Navigation.PlanDirectPath(playerStartTransform.origin, playerStartTransform.origin, playerStartTransform.basis.Quat()); + + foreach (Spatial entity in GetNode("Entities").GetChildren()) + { + Transform entityTransform = entity.Transform; + Vector2 entityPlanePos = new Vector2(entityTransform.origin.x, entityTransform.origin.z); + Vector2 entityOffsetCoordinates = _hexGrid.GetHexAt(entityPlanePos).OffsetCoords; + float entityHeight = _tileWorld.GetHeightAtOffset(entityOffsetCoordinates); + entityTransform.origin.y = entityHeight; + entity.Transform = entityTransform; + } } public void OnWorldGenerated()