- Home /
Network [Command] funktion dont run.
I need to spawn the game map on all clients. Therefor I have buttons the host have acces too. The buttons activate these funktions.
public void Chosemap1()
{
kartanr = 1;
Debug.Log(kartanr);
}
public void Chosemap2()
{
kartanr = 2;
Debug.Log(kartanr);
}
public void Chosemap3()
{
kartanr = 3;
Debug.Log(kartanr);
}
When the game start the void Startmatch is called.
public void Startmatch()
{
if (kartanr == 1)
{
Cmdsm1();
}
if (kartanr == 2)
{
Cmdsm2();
}
if (kartanr == 3)
{
Cmdsm3();
}
}
And depending on what map the host chose. These Comands run.
[Commands]
void Cmdsm1()
{
Debug.Log("cmdsm1 has runned");
GameObject k1 = Instantiate(karta1);
NetworkServer.Spawn(karta1);
}
void Cmdsm2()
{
GameObject k2 = Instantiate(karta2);
NetworkServer.Spawn(karta2);
}
void Cmdsm3()
{
GameObject k3 = Instantiate(karta3);
NetworkServer.Spawn(karta3);
}
The problem is that the commands dont run. I have no idea why, no error or anything, no debug or map is spawned.
Answer by SoshJam · Jun 11, 2018 at 12:58 PM
You don't put [Commands]
in front of a set of commands, you put [Command]
in front of each individual one. That should work.
Your answer
Follow this Question
Related Questions
Characters gun dosent activate on network? 1 Answer
Trying to send command for object without authority. - change color of object from client 0 Answers
"Trying to send command for object without authority" warning but the object is the localPlayer 1 Answer
Unity Networking client interaction with scene not displayed on other client. Commands and RPCs 0 Answers
Non player objects movements are not syncronized on server 0 Answers