Tuesday, April 16, 2024
HomeSample Page

Sample Page Title


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;

    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments