#Scene Migration Synchronization issue
1 messages · Page 1 of 1 (latest)
I can enable it in the Unity sample project that uses Netcode 2.1.1, but when I copy the PlayerSpawner code into my own project, it doesn’t work.
using Unity.Netcode;
using UnityEngine;
namespace Unity.Multiplayer.Samples.SocialHub.Gameplay
{
class PlayerSpawner : NetworkBehaviour
{
[SerializeField]
NetworkObject m_PlayerPrefab;
protected override void OnNetworkSessionSynchronized()
{
Debug.Assert(m_PlayerPrefab != null, $"Prefab reference '{nameof(m_PlayerPrefab)}' is missing or not assigned.");
if (m_PlayerPrefab != null)
{
var spawnPoint = PlayerSpawnPoints.Instance.GetRandomSpawnPoint();
m_PlayerPrefab.InstantiateAndSpawn(networkManager: NetworkManager, ownerClientId: NetworkManager.LocalClientId, isPlayerObject: true, position: spawnPoint.position, rotation: spawnPoint.rotation);
}
base.OnNetworkSessionSynchronized();
}
}
}
the OnNetworkSessionSynchronized() method never gets called
Can you downgrade your NGO to 2.1.1 and see if it works? Could be a bug introduced in later versions.
I upgraded sample the lastest version it still works I couldnt find the difference but mine doesnt work again
The only thing that would stop OnNetworkSessionSynchronized from firing would be if Scene Management was disabled in the Network Manager
:/