Trying to send command for object without authority

Ok so I’m making a multiplayer space shooting game, I’ve had some trouble reducing latency when my ships shoot proyectiles (I used Instancing and spawning on every shot), my next idea was using an object pooling aproach as I had before when protoyping the game on offline mode. I would have a weapon component on my player, a pool size parameter and on awake I would instance the bullets a disable them. I’m trying the same aproach on multiplayer, the thing is when I instantiate the bullet prefabs, prepare them on my local player and then proceed to synchronize them to my clones on the other clients I receive this message even though all bullets are instantiated and initializaed correctly. My player prefab has local authority and I tried giving local autority to the bullet prefab, didn’t work either. Don’t even know if the warning keeps me from doing what I intent, it just bothers me, like I’m doing something wrong, I’m new to networking.

Trying to send command for object without authority

The code for spawning the bullets in my weapon script

void Start()
{
    InitSpawnPositions();
    InitBullets();
    SyncBullets();
}

private void InitBullets()
{
    bullets = new Bullet[poolSize];
    for (int i = 0; i < poolSize; i++)
    {
        bullets[i] = Instantiate(bullet, self.position, self.rotation).GetComponent<Bullet>();
        bullets[i].Init(gameObject);
    }
}

[Client]
private void SyncBullets() {
    CmdSyncBullets(gameObject);
}

[Command]
private void CmdSyncBullets(GameObject parent) {
    for (int i = 0; i < bullets.Length; i++)
    {
        NetworkServer.Spawn(bullets[i].gameObject);
        RpcSyncBullet(bullets[i].gameObject, parent);
    }
}

[ClientRpc]
private void RpcSyncBullet(GameObject bullet, GameObject parent) {
    bullet.GetComponent<Bullet>().Init(parent);
}

My bullet Init Method

public override void Init(GameObject owner)
{
    this.owner = owner.GetComponent<Weapon>();
    this.self.parent = this.owner.Self;
    this.available = true;
    this.lifeCounter = 0f;
    this.gameObject.SetActive(false);
}

I leave the complete files below.

Please help.

3904531–332521–BasicBlaster.cs (3.62 KB)
3904531–332524–BlasterBullet.cs (2.56 KB)

The Start method is run on every object with this script on every client (and the server). You are running a Command off of your Start method. You should be checking if you have authority or if this object is the player object for the local player before trying to run any Commands. Assuming the weapon script is attached to the player gameobject, for n number of players you should expect n-1 number of authority warnings logged on each client as you have it currently set up just for when Start is called on each object on each client.

Thanks for the info, I solved it by calling sync bullets form the override method OnStartAuthority and also checking not to call it from the host as there is nothing to sync technically.

The snippet:

public override void OnStartAuthority() {
    if(!isServer)
        SyncBullets();
}