fix: Address bugs in multiplayer-fps example#597
Open
krazyjakee wants to merge 1 commit into
Open
Conversation
- node-pool: call is_instance_valid() as global function, not method - player: fire death sound and increment deaths only on alive -> dead transition, so they don't multi-trigger while health stays <= 0 - player-input: gate _notification on multiplayer authority so window focus doesn't fan out to every remote player's Input node - bullethole: replace hardcoded scene path with an exported spawn_root Node, falling back to the current scene
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four small bugfixes uncovered while reviewing the
examples/multiplayer-fpsscripts:node-pool.gd—node.is_instance_valid()is invalid;is_instance_validis a global function. Callingclear()would raise. Changed tois_instance_valid(node).player.gd— death sound,deathscounter, anddie()were fired on every tick whilehealth <= 0, so they multi-triggered between damage and respawn (worst on non-authority peers wheredie()early-returns). Now fires once on the alive → dead transition via a local_was_aliveflag.player-input.gd—_notification(NOTIFICATION_WM_WINDOW_FOCUS_IN)ran on every player's Input node in the local tree, so window refocus calledInput.set_mouse_mode(CAPTURED)once per remote player and clearedoverride_mouseon Inputs the local peer doesn't own. Now early-returns for non-authority Input nodes.bullethole.gd— replaced the hardcodedget_tree().root.get_node("multiplayer-fps/Map/StaticBody3D")lookup with an@export var spawn_root: Node, falling back toget_tree().current_scene. The example keeps working without scene edits and the component is reusable elsewhere.Test plan
examples/multiplayer-fps/multiplayer-fps.tscnand host a local serverdeathsincrements by 1