#Call player function from host Netcode

1 messages · Page 1 of 1 (latest)

timber garnet
#

Hello, I am trying to call the GameStart function on all players when the host starts the game. When trying to call this function like I normally would for a non-networked gameObject, it only calls it for the host gameObject. Is there a way to do this built in to Netcode or should I do it by making a network variable on the player script that I can change and just call GameStart when the player detects that the variable is set to the right condition?

limpid glacier
#

You either need to wait for all clients to load in first. Or you can put StartGame() inside the player's OnNetworkSpawn. There are also scene events you can use

timber garnet
# limpid glacier You either need to wait for all clients to load in first. Or you can put StartGa...

The StartGame function is being called after the players have already joined in the game and is being used to unfreeze player movement when the host hits play. Should this code work and I just messed something up? I set up a debug and tested it, and it is working for the host but does not get called on the clients. Also, if I let the clients also have the button, the button works for each individual player, but does not seem to be able to affect other players.

limpid glacier
#

You'll need to RPCs for that