- Home /
Trying to store a variable for all clients
This is probably a very simple problem but I would just want to know the best way to do this. I am spawning AI objects in a multiplayer game when the host hosts the game. The script to spawn the AI is on the player object which is probably not ideal but works fine. When another client joins, he should not spawn AI objects because they are already spawned. I currently have a dedicated object with a Network Identity and a class with just a [SyncVar] bool called hasSpawnedAI which is initially false. Once the host has created the room and the AI objects have been spawned this bool becomes true; When a client joins he checks for this bool and if it is false he does not spawn the AI objects.
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Force local client RPC to fire immediately? 0 Answers
Network Client Connecting with different Maps 3 Answers
Connect Client to Server from a Different project 0 Answers
Connect to remote private IP 1 Answer