Here’s my code:
using UnityEngine;
using UnityEngine.Networking;
public class Player : NetworkBehaviour {
[SerializeField]
private int maxHealth = 100;
[SyncVar]
private int currentHealth;
void Awake ()
{
SetDefaults();
}
public void TakeDamage (int _amount)
{
currentHealth -= _amount;
Debug.Log(transform.name + " now has " + currentHealth + " health.");
}
public void SetDefaults ()
{
currentHealth = maxHealth;
}
}
But when I enter SyncVar as the attribute above the current health, it stays grayed out and has no function.