diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 890ed23..c0ed3a9 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -731,7 +731,7 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) var mat := StandardMaterial3D.new() mat.roughness = 0.65 - var y_offset : float + var above_tile : float # how far above the tile top the body centre sits match card_type: "ArchSpirit": var cyl := CylinderMesh.new() @@ -743,7 +743,7 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) var cs := CylinderShape3D.new() cs.radius = 0.22; cs.height = 0.8 shape.shape = cs - y_offset = tile_h + 0.4 + above_tile = 0.4 "Ruin": var bm := BoxMesh.new() bm.size = Vector3(0.25, 1.0, 0.25) @@ -752,7 +752,7 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) var bs := BoxShape3D.new() bs.size = Vector3(0.25, 1.0, 0.25) shape.shape = bs - y_offset = tile_h + 0.5 + above_tile = 0.5 _: var sm := SphereMesh.new() sm.radius = 0.28; sm.height = 0.28 @@ -761,7 +761,7 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) var ss := SphereShape3D.new() ss.radius = 0.28 shape.shape = ss - y_offset = tile_h + 0.28 + above_tile = 0.28 mi.material_override = mat if exhausted: @@ -769,7 +769,8 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) body.add_child(shape) body.add_child(mi) - body.position = wp + Vector3(0, tile_base + y_offset, 0) + body.set_meta("above_tile", above_tile) + body.position = wp + Vector3(0, tile_base + tile_h + above_tile, 0) _units_root.add_child(body) _unit_meshes[iid] = mi _unit_bodies[iid] = body @@ -1280,11 +1281,9 @@ func _animate_unit_move(iid: String, from_coord: Vector2i, to_coord: Vector2i, step_angles.append(atan2(dir.x, -dir.z) - base_angle) prev_coord = step # Tween the body through each grid step, rotating the model to face each direction. - # Compute how far above the tile top this unit sits so we can preserve that - # offset as it moves across tiles of different stagger heights. - var from_key := "%d,%d" % [from_coord.x, from_coord.y] - var from_tile_top : int = _tile_y_bases.get(from_key, 0.0) + _tile_heights.get(from_key, 1.0) - var unit_above : float = body.position.y - from_tile_top + # Use the stored "above_tile" constant so rapid state updates cannot skew the + # height by back-calculating from a mid-tween body position. + var unit_above : float = body.get_meta("above_tile", 0.28) # Pre-compute per-step Y positions. var step_ys : Array[float] = [] for step : Vector2i in path: