Home Game Development unity – How to spawn object in a multiplayer sport, with out triggering “NetworkClient just isn’t prepared” error?

unity – How to spawn object in a multiplayer sport, with out triggering “NetworkClient just isn’t prepared” error?

0
unity – How to spawn object in a multiplayer sport, with out triggering “NetworkClient just isn’t prepared” error?

[ad_1]

I’m attempting make a multiplayer sport, utilizing Mirror, however cannot get the well being indicator to spawn. An error message seems:

Send command tried whereas NetworkClient just isn’t prepared.

utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
utilizing UnityEngine.UI;
utilizing Mirror;

public class IndicatorsPlayer : NetworkBehaviour
{
[SerializeField]
    personal GameObject IndicatorsPlayerPrefab;
   
    [SerializeField]
    personal Image bar;

    [SerializeField]
    personal float fill = 1f;

    void Update ()
    {
        if(this.isLocalPlayer)
        {
            this.CmdSpawnIndicatorsPlayer();
           
        }
    }

    [Command]
    void CmdSpawnIndicatorsPlayer()
    {
    GameObject IndicatorsPlayer = Instantiate(IndicatorsPlayerPrefab, this.rework.place, Quaternion.id);
            NetworkServer.Spawn(IndicatorsPlayer);
            fill -= Time.deltaTime * 0.1f;
        bar.fillAmount = fill;

    }
}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here