r/Unity3D • u/CharlesTitor • 14d ago
Noob Question How to put multiple characters on a multi-player game
Not very experienced with Unity but got over-ambitious and started making a multi-player shooter game with different characters. From the tutorials I've checked out I'm using Netcode for GameObjects and as far as i understand the Network Manager only accepts one Default Player Prefab, but I haven't been able to find any that shows how to add multiple player prefabs. I just want the character spawning and FPS control to be in a functional state for now. Advice, help, and links to tutorials would be appreciated. Thank you in advance.
3
Upvotes
2
u/Kamatttis 14d ago
There can be multiple ways to do this like changing the models through rpc, or creating your own spawner. Either way, you'll need substantial amount of knowledge of programming, as well as networking.
1
u/DapperNurd 14d ago
Maybe make a class responsible for spawning whatever character you need, like a super, selector class. Then make that class the multi-player one.
1
u/4Hands2Cats-4H2C 14d ago
You make an abstract player prefab. It would be spawn for the networking to have its observer. Then you are free to do what ever you want.
1
u/Artuplabs 14d ago
you don't need the default player prefab at all. what i'd do with ngo:
if the choice is made before joining (menu screen), the other way is connection approval: the client puts its pick in the connection payload and the server sets
response.PlayerPrefabHashto the matching prefab, then ngo spawns the right one automaticallyfor fps control just check
IsOwnerin the controller and disable input + camera on everyone else's copy, that's the part most tutorials skip1
u/DrZoidar 13d ago
Default Player Prefab is just the default, u don't have to use it. Add all ur char prefabs to the Network Prefabs List, enable Connection Approval + set CreatePlayerObject = false so nothing auto-spawns. Then let the player pick a char in a menu, send the index to the server w/ a ServerRpc, and the server instantiates it + calls SpawnAsPlayerObject(clientId).
Only gotcha is the RPC needs to be on something that already exists when they join (e.g. a scene GameManager), not the player prefab. Gl!
1
u/glenpiercev 13d ago
Unity has a template for this that you should look into.