Fix weapons not working on client: remove is_predicting check + init loadout
- Removed the is_predicting() early-return in weapon_manager._rollback_tick which blocked all weapon actions on the client (player owned by server) - Added client-side weapon loadout initialization in player-spawner._spawn so the player has weapons immediately, before server state sync arrives - Server reconciles via rollback state sync Movement was fixed in v0.2.2 (window focus grab). This addresses the remaining 'can't switch or use weapons' issue.
This commit is contained in:
@@ -158,10 +158,13 @@ func give_weapon(weapon_id: int):
|
||||
NetworkRollback.mutate(self)
|
||||
|
||||
func _rollback_tick(delta: float, tick: int, _is_fresh: bool):
|
||||
if rollback_synchronizer.is_predicting():
|
||||
return
|
||||
# NOTE: On the client, the player CharacterBody3D is owned by the server
|
||||
# (peer 1), so `rollback_synchronizer.is_predicting()` may return true
|
||||
# on early ticks when input history hasn't been built up yet.
|
||||
# We process weapon actions anyway — the server reconciles via rollback.
|
||||
# Only skip if the player is dead or frozen (checked below).
|
||||
|
||||
# DEBUG: weapon switching
|
||||
# Skip if player dead
|
||||
if input and (input.slot_1 or input.slot_2 or input.slot_3 or input.slot_4):
|
||||
print("[WEAPON DEBUG] _rollback_tick tick=%d slots=[s1=%s s2=%s s3=%s s4=%s] active=%d inv=%s" % [tick, input.slot_1, input.slot_2, input.slot_3, input.slot_4, active_slot, inventory])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user