I scripted this code in c#:
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
class EnemySpawnClient : NetworkBehaviour{
public GameObject TankPref;
[Command]
void CmdTankFire () {
if (!isLocalPlayer)
return;
GameObject Tank = (GameObject) Instantiate (TankPref, transform.position, transform.rotation);
NetworkServer.Spawn (Tank);
}
}
Now my problem is that when I call the function “CmdTankFire” as a client the GameObject “TankPref” dosnt spawn on the server and on the client (It dosent spawn at all). But when I call this function as a host it spawns on the client and on the server (both). So my question is how can I edit this script so I can spawn the “TankPref” as a client too;
Thanks in advance.
Ps: I attached the script to the Client Player and to the Server Player