I was just wondering if there were examples of all three spawning modes (delayed, predicted, and player spawned) in the current netcode samples.
For future reference because I have no clue what I’m looking at, can you please provide file names and line numbers of each instance in the asteroids sample.
So just calling EntityManager.Instantate() forms these predictions and the location, whether inside the predicted loop or on the client or both, determines the spawn category?
Correct. If you notice, there is (correction) only one bit of code in the SteeringSystem
that is client specific.
isFirstFullTick == 1
(which is populated via the NetworkTime
singleton).
Because it’s in the PredictedSimulationSystemGroup
, it’ll run identically on both the client and server. The only nuance is that on the client, prediction runs multiple times per frame, so isFirstFullTick ensures that you only create the bullet once on the client (the first time you predict this frame). I recommend reading this manual on prediction: https://docs.unity3d.com/Packages/com.unity.netcode@1.0/manual/prediction.html
In earlier versions you had to explicitly define a client ghost as a predicted spawn (via an API), but we were able to remove that in 1.0. See CHANGELOG.md entry:
- The GhostCollectionSystem.CreatePredictedSpawnPrefab API is deprecated as clients will now automatically have predict spawned ghost prefabs set up for them. They can instantiate prefabs the normal way and don’t need to call this API.
1 Like