Hello i have been reading recently lot of issues and problems when running on NGO, regarding to client spawning, as client spawning is a thing that initially NGO is not designed for, but still there some undocumented ways to make it work.
Today i want to bring a little Git repo to share with you how to make a super easy client predicted spawn with a basic, and an advanced implementation NGO-ClientPredictedSpawn GIT Repository
Please let me know if this helps
Edit:
Current NGO versions already integrated my pull request that i worked with the unity team for solving this issue much more cleanly
Taking a quick look at your code, it’s interesting! Is the idea here that the local client uses a standard Instantiate to create an instance of a prefab instantly, then sends the command to the server to Spawn it as a network object, and then destroys the local instance once the server one spawns to replace it? Is this intended to eliminate apparent network lag in clients spawning objects? It’s a cool approach!
There are a few issues I can imagine arising with this approach:
For an object to correctly spawn for everyone, it has to be added to everyone’s Network Prefab list before the Spawn call happens. Effectively this means at least one of each of your spawners needs to be in the scene at load time, new spawners can’t be created at runtime unless one of them already exists in the scene. That’s not a problem, just a known limitation.
If you’re spawning more complex items, their behaviours won’t necessarily match until the true item spawns. If it has a rigidbody for example, physics will be reset when the new one spawns in. You’ll be able to attempt to interact with the Client-instantiated version but any interactions that are supposed to happen via NetworkBehaviours will throw errors. Any initialisation that happens in OnNetworkSpawn also won’t be run on the instantiated version, will it?
Anything random in the spawned object will need to be deterministic as the Instantiated version and Spawned version will be different. That’s fine though because you’d need to do that anyway to ensure every client has the same spawned version.
Not exactly, you never replace your local instance, youre indeed linking the existing instance to the networked one the server spawned, and as the server is giving the ownership upon spawning the client wont see anything wrong, so these problems are common on client prediction solutions, nothing that cant be solved depending on the needs
also this is a basic solution that can be extended, i use it on other project and dynamically add network prefab to the network manager depending on the level load
about the whestion you say of network bejaviours, yes, they do their network events, just because they are indeed spawning just the spawn and intantiate method are overriden using PrefabInstanceHandlers
About the last, exactly what you say, you would need to make it to be deterministic, but the main problem which is resets should not exist, as youre linking an existing object to the server, not creating and replacing