Unity: 2022.3.30f1
NetCode: 1.2.1
What I do: Set up SubScene, put “PlayerSpawnerAuthoring” there, created a client-server connection.
In ‘OnCreate’ declared system systemState.RequireForUpdate(), in ‘OnUpdate’ get acces from
PlayerPrefab, and Instantiate him in ‘entityCommandBuffer’.
Result: The connection is successful, the player does not appear, the entity is not created. It’s amazing.
I did everything according to the lesson from the documentation.
In addition, errors that are clearly unrelated to my code are constantly appearing in the console. At the engine level.
Through tests, I found out that my entity system is not working. OnUpdate is not happening.
At the same time, the Sub Scene Bake-service is working fine. But the entity is not created.
Probably because before “entityCommandBuffer.Instantiate(playerPrefab)” just not executed in OnUpdate.
And this is the main problem, after OnCreate the system stops.
If remove a single line “systemState.RequireForUpdate” all RPCs reach from the client to the server and all works fine.
I did everything according to the lesson, and my Update does not work.
And If I remove any mentions of PlayerPrefab in the system code, everything works fine…
I’ve been looking for a problem for the second day, it hurts me, Unity.
I’m one step away from using NetCode for GameObjects.
UPD. Apparently, PlayerPrefab(IComponentData Entity) is not created after Bake. But this does not resolve the issue, I do not know why this is happening.
Final: I fixed that. The obvious bug is that bake is triggered event in a scene that has not been loaded. This is not an expected behavior for a person who has just started to get acquainted with the system. Bake should not work and triggered in a scene if scene has not been loaded for entities.
It took me more than 4 days…