fix so smoke correctly syncs
This commit is contained in:
@@ -260,6 +260,7 @@ func _physics_process(delta: float) -> void:
|
||||
$SfxDrag2.play()
|
||||
else:
|
||||
is_moving = false
|
||||
$GPUParticles2D.emitting = false
|
||||
if $SfxDrag2.playing:
|
||||
$SfxDrag2.stop()
|
||||
previousFrameVel = velocity
|
||||
@@ -440,24 +441,20 @@ func _physics_process(delta: float) -> void:
|
||||
elif is_being_grabbed and holder_peer_id != 0:
|
||||
# Only handle visual/audio effects on client, don't move the pot
|
||||
# The server handles the actual movement and syncs position via replication
|
||||
# is_moving is already replicated from server, so use that to control particles
|
||||
if holder != null and holder.get_multiplayer_authority() == holder_peer_id:
|
||||
# Check if pot appears to be moving (based on position changes from server)
|
||||
var pot_movement = global_position - previous_client_position
|
||||
|
||||
# If pot has moved, it's being pushed/pulled
|
||||
if pot_movement.length() > 0.5:
|
||||
is_moving = true
|
||||
# Use replicated is_moving state to control particles (more efficient than syncing emitting)
|
||||
if is_moving:
|
||||
# Keep particles emitting continuously while moving (don't let timer stop them)
|
||||
$GPUParticles2D.emitting = true
|
||||
# Continuously restart timer while moving to keep particles emitting (like server does)
|
||||
$GPUParticles2D/TimerSmokeParticles.start()
|
||||
if !$SfxDrag2.playing:
|
||||
$SfxDrag2.play()
|
||||
else:
|
||||
is_moving = false
|
||||
$GPUParticles2D.emitting = false
|
||||
if $SfxDrag2.playing:
|
||||
$SfxDrag2.stop()
|
||||
|
||||
# Update previous position for next frame
|
||||
previous_client_position = global_position
|
||||
else:
|
||||
# No valid holder, clear state
|
||||
is_being_grabbed = false
|
||||
@@ -947,5 +944,8 @@ func _on_area_2d_pickup_body_exited(_body: Node2D) -> void:
|
||||
|
||||
|
||||
func _on_timer_smoke_particles_timeout() -> void:
|
||||
$GPUParticles2D.emitting = false
|
||||
# Only stop particles if pot is not moving (for one-time effects like landing)
|
||||
# If pot is being pushed/pulled, keep particles emitting
|
||||
if not is_moving:
|
||||
$GPUParticles2D.emitting = false
|
||||
pass # Replace with function body.
|
||||
|
||||
Reference in New Issue
Block a user