Unet, Spawning the player prefab manually

Hi,

I’m trying to do a team based prototype with unet. I’m trying to spawn the player prefab after the client has connected to the server and has chose his/her team. The first thing I did is to uncheck the Auto Create Player in my NetworkManager. Then I’ve found the NetworkServer.AddPlayerForConnection(conn, player, playerControllerId) method, but it needs a connection and a playerControllerId parameter that are passed when the OnServerAddPlayer method is called. But it’s not called because of the Auto Create Player set to false.

Do you have an idea of how I can achieve this ?

Thx in advance :slight_smile:

1 Like

I’m also looking into this. Try running the code from OnServerAddPlayer or cache the connection from that function somewhere and run it where you’re trying to. That’s what I’m going to try momentarily.

And of course I mean to run the code in the appropriate event. I’ll probably get this wrong a few times as it’s all new to me :smile:

–edit

It would appear I can’t figure it out. My answer until further notice is screw it & make your default player an empty object that can run the functions you want to run before spawning its body.

1 Like

:confused: In my case I have let the default player spawn and disabled all the renderers and the input scripts. I then added a “PlayerStatus” scripts that re-activates the renderers and the input scripts as soon as the player select his/her team. It works but it’s not really nice :smile:

1 Like

We’re making the best of what’s built in and easy to use haha