I'm trying make a multiplayer game, using Mirror, but can't get the health indicator to spawn. An error message appears:
Send command attempted while NetworkClient is not ready.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Mirror;
public class IndicatorsPlayer : NetworkBehaviour
{
[SerializeField]
private GameObject IndicatorsPlayerPrefab;
[SerializeField]
private Image bar;
[SerializeField]
private float fill = 1f;
void Update ()
{
if(this.isLocalPlayer)
{
this.CmdSpawnIndicatorsPlayer();
}
}
[Command]
void CmdSpawnIndicatorsPlayer()
{
GameObject IndicatorsPlayer = Instantiate(IndicatorsPlayerPrefab, this.transform.position, Quaternion.identity);
NetworkServer.Spawn(IndicatorsPlayer);
fill -= Time.deltaTime * 0.1f;
bar.fillAmount = fill;
}
}
NetworkClient.ready
? \$\endgroup\$