Fix: animation loop glitch + seamless one-shot → idle transition
Rewrote tween_callback lambda in _animate_unit_move to use a local captured variable instead of .bind(), fixing the GDScript indentation parse error on line 1018. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -1008,15 +1008,14 @@ func _animate_unit_move(iid: String, from_coord: Vector2i, to_coord: Vector2i,
|
||||
tween.set_ease(Tween.EASE_IN_OUT)
|
||||
tween.set_trans(Tween.TRANS_SINE)
|
||||
for i in path.size():
|
||||
var step : Vector2i = path[i]
|
||||
var wp := _coord_to_world(step.x, step.y)
|
||||
var step : Vector2i = path[i]
|
||||
var wp := _coord_to_world(step.x, step.y)
|
||||
var facing_angle : float = step_angles[i] # captured per-iteration
|
||||
# Snap model rotation to face the movement direction before each step.
|
||||
tween.tween_callback(
|
||||
(func(angle: float) -> void:
|
||||
var m := _unit_meshes.get(iid) as Node3D
|
||||
if is_instance_valid(m):
|
||||
m.rotation.y = angle
|
||||
).bind(step_angles[i]))
|
||||
tween.tween_callback(func() -> void:
|
||||
var m := _unit_meshes.get(iid) as Node3D
|
||||
if is_instance_valid(m):
|
||||
m.rotation.y = facing_angle)
|
||||
tween.tween_property(body, "position", Vector3(wp.x, body_y, wp.z), MOVE_STEP_SECS)
|
||||
# Return to idle rotation and idle animation once movement finishes.
|
||||
tween.tween_callback(func() -> void:
|
||||
|
||||
Reference in New Issue
Block a user