Question by
KillitsGaming · Apr 25, 2016 at 11:08 PM ·
c#uinetwork
Hi need help with a multiplayer FPS ammo display UI text C# over the network
Hi I am trying to get a ammo display but cant get the UI text to set to the instanced player prefab ammo count or is there a better way of doing this Thank you .
public int maxAmo = 120; public int curnAmo; public int maxClip;
public int curClip; public Text curAmoText; public Text curClipText;
void Start ()
{
if (isLocalPlayer)
{
curnAmo = maxAmo;
curClip = maxClip;
amoDisplayPrefabInsatances = Instantiate (amoDisplayPrefab);
amoDisplayPrefab.name = amoDisplayPrefabInsatances.name;
curAmoText = GetComponent<UnityEngine.UI.Text> ();
curClipText = GetComponent<UnityEngine.UI.Text> ();
}
}
void Update(){
RpcSetAmo ();
}
[ClientRpc]
void RpcSetAmo()
{
curAmoText.text = " " + curnAmo.ToString ();
curClipText.text = " " + curClip.ToString ();
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612075622im_/https://answers.unity.com/themes/thub/images/avi.jpg)