Godot Version
4.3
Question
I’m making a simple multiplayer game to learn the basics and got stuck in this situation:
I have a script that spawns power-ups in the map. These power-ups scenes are on the MultiplayerSpawner list, and have a MultiplayerSynchronizer inside, which synchronizes the position, like this:
This works fine, the server instantiates the nodes and they get synced with the clients.
These power-ups have a script that queue_free
them when a player enters the area:
extends Area3D
const LIFE_AMOUNT := 50
func _on_body_entered(body: Node3D) -> void:
if !is_multiplayer_authority():
return
if body is Tank:
body.increase_health.rpc_id(body.get_multiplayer_authority(), LIFE_AMOUNT)
queue_free()
Which also works fine, but only when this node is instantiated via code. If I place this node on the game map via the editor and then play the game, it only disappears when the host enters the area, and only on the host’s game.
For example, if a host enters the area, the node is deleted only on the host, while clients still see it. If the client enters the area, the node is deleted only on the host, but stays there on the client.
I’m probably doing something wrong, but I can’t figure out what.
This is the world nodes:
This is the MultiplayerSpawner configuration:
And the MultiplayerSynchronizer on the node:
Thanks in advance!