Godot Version
4.5.1
Question
From my Menu scene, client can join server (multiplayer)
Instead of loading scene with change_scene_to_file(), I want to use ResourceLoader
Problem is : My first player seems ok (Howerver, The multiplayerSynchronizer from one nested scene doesn’t work anymore) and then the second player joining spawn only from the view of the server and player 1. Player 2 doesn’t even see himself spawning in the game. His multiplayerSpawner doesn’t even sync. Not sure what is wrong with the code.
I put in the method “process2” the old way to load directly my scene, which is working
(it doesn’t make sens to put these line in the process method but it’s just to compare)
any idea how to fix this strange bug ?
extends Control
func _ready():
if DisplayServer.get_name() == "headless":
NetworkManager.host_game()
func _on_join():
NetworkManager.playerName=%NameInput.text
NetworkManager.join_game(%AddressInput.text)
multiplayer.connected_to_server.connect(_on_connection_success)
func _on_connection_success():
ResourceLoader.load_threaded_request(target_scene_path)
loading = true
%Loading.visible=loading
var loading = false
@export_file("*.tscn") var target_scene_path: String
var progress = []
func _process(_delta: float) :
if loading :
var status = ResourceLoader.load_threaded_get_status(target_scene_path, progress)
%Loading.value = progress[0] * 100
if status == ResourceLoader.THREAD_LOAD_LOADED:
loading = false
var new_scene = ResourceLoader.load_threaded_get(target_scene_path)
get_tree().change_scene_to_packed(new_scene)
%Loading.visible = loading
func _process2(_delta: float) :
if loading :
loading = false
get_tree().change_scene_to_file("res://scenes/Game.tscn")
EDIT/NOTE : I got the same problem when using get_tree().change_scene_to_file(“res://scenes/Game.tscn”) just after :
if status == ResourceLoader.THREAD_LOAD_LOADED:
so it seems to come from ResourceLoader state ?