- Home /
Cant Sync UI over UNET
Hello!. I need to make playerHealth with UI. Everything works fine but when i join with another player, i cant see the UI.
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
public class PlayerStats : NetworkBehaviour
{
NetworkConfigurator netConf;
[SyncVar]
public float playerHealth;
void Start ()
{
netConf = GameObject.Find ("NetworkManager").GetComponent<NetworkConfigurator> ();
netConf.userStatus.SetActive (isLocalPlayer); // Here the problem
}
void Update ()
{
if (Input.GetKeyDown (KeyCode.LeftBracket))
{
if (playerHealth == 0)
return;
playerHealth -= 5;
}
if (Input.GetKeyDown (KeyCode.RightBracket))
{
if (playerHealth == 100)
return;
playerHealth += 5;
}
netConf.healthAmount.text = "" + playerHealth;
netConf.healthBar.fillAmount = playerHealth / 100;
}
}
Help please :з
Comment
Your answer
Follow this Question
Related Questions
Spawn dynamic players over network 0 Answers
I need help with the player's health points 1 Answer
Lists over a network 1 Answer
Photon Network Health Script 0 Answers
How to approach DLC for standalone and web build games? 1 Answer