Spawning & Respawning Player Via Script in Distributed Authority

Hey all, I’m loving the new distributed authority system. There are few things that seem like they’re still WIP, which is understandable, but I thought I’d ask on this forum in case I missed anything.

One of those things is spawning player objects via script. Calling the old NetworkObject.SpawnAsPlayerObject() function in Distributed Authority doesn’t seem to work. It spawns the object successfully, but as a vanilla non-player object. As a result, the player has no authority over themselves, and important properties like IsLocalPlayer are marked as false.

It seems like the only way to spawn players right now is via the NetworkManager prefab slot.

Is there a new way to spawn player objects via script, or is this still unfinished in distributed authority mode?

Glad to here you are enjoying it! :smiley:

In NGO v2.0.0, we have added a new way to handle overriding the spawning of a player prefab. You can assign a handler to NetworkManager.OnFetchLocalPlayerPrefabToSpawn where you just return whatever registered network prefab you want to be spawned as the player. So, you can assign a generic player prefab and then override that if you want when it is time to spawn the player.

The other way is to just not assign a player prefab in the NetworkManager and then handle spawning on your own.

This applies to both client-server and distributed authority network topologies.

Let me know if this helps you resolve your issue?

Hey Noel,

That sounds like what I was looking for - thank you!