SyncVar, Command and Authority problem
Hello everyone! I'm starting to use UNET functionalities, and I have some problem with Synchro info between clients... The player is a prefab spawning throught networkmanager.
I need to Synchronize a Var called "ActiveZone", it's a bolean, and I'm using it for detecting when any user is on a zone, throught a OnTriggerEnter cube item, called "SpawnTrigger", inside the SpawnManager.
Right now, I can active the trigger zone from the HOST , and SyncVar does it's work activating it on the clients. The problem comes, when a CLIENT gets inside the zone, it doesnt syncro (since Syncvar is only server->client). I tried using a "Command", but I might have something wrong, because when launching the command, I get in console: "Trying to send command for object without autority" in Client side.
I will show you my setup:
This script is attached to SpawnTrigger Object
###Spawn.cs###
public class Spawn : NetworkBehaviour {
public GameObject enemy;
public Transform SpawnPoint_1;
public Transform SpawnPoint_2;
public Transform SpawnPoint_3;
public Transform SpawnPoint_4;
public Transform SpawnPoint_5;
public int EnemyCoord_Y = 0;
public int Range = 35;
public string EnemyTagName;
public int MaxEnemysSpawned = 15;
public int SpawnDelay = 5;
public int EnemysSpawned = 0;
[SyncVar]
public bool ActiveZone;
public GameObject[] EnemyArray;
[Command]
void CmdActiveZone()
{
ActiveZone = true;
}
void Start () {
}
void OnTriggerEnter (Collider other) {
if (other.gameObject.tag == "Player")
{
if (!isServer)
{
CmdActiveZone();
}else
{
ActiveZone = true;
}
}
}
This is not my video, but i have same scenario than this one, except for I have Local player and server only unchecked... : https://www.youtube.com/watch?v=RXEWM_Nc_K8
Answer by eLementZZZ · Aug 13, 2017 at 02:21 PM
Solved myself, called it on player object and problem dissapeared.