Question by
SNorth12 · Oct 23, 2021 at 11:09 AM ·
networkingmultiplayermirror
Mirror Network does not have authority
Hi All,
I'm sorry if I am missing something very obvious, but I am afraid I have got myself confused. I am implementing a system using Mirror where players can spawn a projectile, and the destroy that projectile by clicking a UI button. The code I have is as follows:
[Command]
public void CmdSpawnProjectile(Quaternion initialRotation, Vector3 spawnPosition)
{
GameObject projectileInstance = Instantiate(projectilePrefab, spawnPosition, initialRotation);
NetworkServer.Spawn(projectileInstance, connectionToClient);
projectileQueue.Enqueue(projectileInstance);
}
public void DestroyProjectile()
{
CmdDestroyProjectile();
}
[Command]
public void CmdDestroyProjectile()
{
if (projectileQueue.Count <= 0) { return; }
GameObject projectileIn = projectileQueue.Dequeue();
NetworkServer.Destroy(projectileIn);
}
There is seemingly no issue with spawning, and when playing with one client it works perfectly. Add a second client and the host clients destruction of projectile doesn't work stating that it doesn't have authority. Please help if you can!
Comment