This commit is contained in:
2026-01-15 09:07:56 +08:00
parent bee9c30f0e
commit 5a97f7959e
4 changed files with 77 additions and 7 deletions
+1
View File
@@ -61,6 +61,7 @@ script = ExtResource("2_hbe1v")
columns = 14
rows = 14
floors = 2
auto_randomize = true
metadata/_editor_floor_ = Vector3(0, 1, 0)
[node name="Camera3D" type="Camera3D" parent="."]
+12 -3
View File
@@ -616,9 +616,14 @@ func _process(delta):
rpc("ping_existence")
else:
# Client-side visual smoothing
# Interpolate towards the target position received from authority
if global_position.distance_squared_to(target_visual_position) > 0.001:
global_position = global_position.lerp(target_visual_position, delta * 15.0)
# Only interpolate if NOT running a movement tween, OR if the drift is large (teleport/snap)
if not is_player_moving:
# Snap to target if very close (prevents micro-jitter)
if global_position.distance_squared_to(target_visual_position) < 0.001:
global_position = target_visual_position
else:
# Interpolate towards the target position received from authority
global_position = global_position.lerp(target_visual_position, delta * 15.0)
# Delegate rotation to movement manager
if movement_manager:
@@ -841,6 +846,10 @@ func start_movement_along_path(path: Array, clear_visual: bool = true):
is_player_moving = false
target_position = Vector2i(-1, -1)
# FORCE SNAP: Update target visual position to the perfect grid center
# This ensures that when interpolation resumes (in _process), it pulls to the correct spot
target_visual_position = grid_to_world(current_position)
# Check if we've reached the finish line (uses lap-aware finish locations)
var current_finish_locs = race_manager.get_current_finish_locations() if race_manager else finish_locations
if current_position in current_finish_locs and can_finish: