Godot Version
4.5.stable
Question
I have a NetworkManager global script for managing network links. I would like to set up a Spawner node for generating player information and directly use it as a child node of the Spawner.
I tried to generate it using code, but I encountered an issue when setting the spawn_math: I cannot set it through NodePath (“PlayerConfigCollection”), it will prompt Cannot find the spawnnode and must use an absolute path (as shown below). Why is this? Is it appropriate to use an absolute path directly?
func _ready() -> void:
generate_player_config_spawner()
# 生成玩家配置集合节点
func generate_player_config_spawner()->void:
var player_config_spawner: MultiplayerSpawner = MultiplayerSpawner.new()
player_config_collection = player_config_spawner
self.add_child(player_config_spawner)
player_config_spawner.name = "PlayerConfigCollection"
player_config_spawner.spawn_function = _add_player_config_function
player_config_spawner.spawn_path = "/root/NetworkManager/PlayerConfigCollection"
player_config_spawner.spawn_limit = 0
player_config_spawner.add_spawnable_scene(player_config_path)