diff --git a/scenes/Game.cs b/scenes/Game.cs index df8a6b0..549535f 100644 --- a/scenes/Game.cs +++ b/scenes/Game.cs @@ -269,7 +269,6 @@ public class Game : Spatial public void OnTileHovered(HexTile3D tile) { Transform highlightTransform = tile.GlobalTransform; - highlightTransform.origin.y += 0.1f; _mouseTileHighlight.Transform = highlightTransform; _mouseWorldLabel.Text = highlightTransform.origin.ToString(); _mouseTileOffsetLabel.Text = tile.OffsetCoords.ToString(); diff --git a/scenes/TileWorld.cs b/scenes/TileWorld.cs index ad68efd..1fbf99a 100644 --- a/scenes/TileWorld.cs +++ b/scenes/TileWorld.cs @@ -40,7 +40,7 @@ public class TileWorld : Spatial [Export] public int Size = 64; [Export] public bool DebugMap; - public float HeightScale = 2.0f; + public float HeightScale = 1.0f; public Image HeightmapImage; public Image ColormapImage; public Image NavigationmapImage; @@ -293,7 +293,7 @@ public class TileWorld : Spatial Spatial assetInstance = (Spatial)assets[assetIndex].Duplicate(); Transform assetTransform = Transform.Identity; assetTransform.origin = GetHexCenterFromOffset(offsetCoord); - assetTransform.origin.y += 1.2f; + assetTransform.origin.y = GetHeightAtOffset(offsetCoord); assetTransform.basis = assetTransform.basis.Rotated(Vector3.Up, (float)(randomGenerator.NextDouble() * Mathf.Pi * 2)); assetInstance.Transform = assetTransform; @@ -364,7 +364,7 @@ public class TileWorld : Spatial Chest chestAsset = (Chest)_chestScene.Instance(); Transform assetTransform = Transform.Identity; assetTransform.origin = GetHexCenterFromOffset(offsetCoord); - assetTransform.origin.y += 1.2f; + assetTransform.origin.y = GetHeightAtOffset(offsetCoord); chestAsset.Transform = assetTransform; Entities.AddChild(chestAsset); MarkCellUnwalkable(cell); @@ -461,14 +461,18 @@ public class TileWorld : Spatial Vector2 textureCoord = OffsetToTextureCoord(offsetCoord); - float heightmapHeight = HeightmapImage.GetPixel((int)textureCoord.x, (int)(textureCoord.y)).r; + float heightmapHeight = (HeightmapImage.GetPixel((int)textureCoord.x, (int)(textureCoord.y)).r - 0.5f) * HeightScale; - if (heightmapHeight > 0.5) + if (heightmapHeight <= 0) { - heightmapHeight = 0.6f; + heightmapHeight -= 0.03f; + } + else + { + heightmapHeight = 0f; } - return heightmapHeight * HeightScale; + return heightmapHeight; } diff --git a/utils/TileHighlight.tscn b/utils/TileHighlight.tscn index 9b01a40..3509cab 100644 --- a/utils/TileHighlight.tscn +++ b/utils/TileHighlight.tscn @@ -20,7 +20,7 @@ roughness = 0.0 [node name="TileHighlight" type="Spatial"] [node name="TileMesh" type="MeshInstance" parent="."] -transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, -0.05, 0 ) +transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0 ) cast_shadow = 0 mesh = SubResource( 3 ) skeleton = NodePath("../..")