Properly place entities at their corresponding heights.

WorldChunkRefactoring
Martin Felis 2023-05-21 17:29:44 +02:00
parent 866fd11399
commit 555982262f
1 changed files with 10 additions and 0 deletions

View File

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