#When a client join the network, how do i execute code, along with get the clients connection?

16 messages · Page 1 of 1 (latest)

wicked lily
#

depends on what code you want executed. NetworkManager has some callbacks like onserverconnect etc

#

the client will not get it's own connection. What exactly are you looking to do?

#

so do you have a room in mirror? I assume Player is a script?

#

i know what's photon I just never used it

#

so what are you doing in mirror to create the room?

#

so you are copying someone's code?

#

so how are you making a room in the first place? you might want to check out the mirror examples, like roomnetworkmanager etc

#

you said you wanted to recreate it.

#

🤷‍♂️

#

so what exactly do you want to do, when a client connects?

#

on the server machine or on the client machine?

#

because only the server machine will know which client is which connection, callback is OnServerConnect (NetworkConnection conn) something like that.

#

on the client, you have OnClientConnect but that's only for that 1 machine connecting to the server.

#

If you are looking to do something, when for example Client A joins server, and then client B joins server, and you want something to be done on Client A's machine, look into doing that upon spawning of their own player object

#

public, no parameters

#

in a class inheriting from NetworkManager