hey! im trying to network my mobs health across the game as multiple players can attack the mob but im having a hard time here is my current script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;
using UnityEngine;
public class MobID : NetworkBehaviour {
public string MOBID;
public int Health = 100;
public int MaxHealth = 100;
GameObject MyHealth3D;
void Start()
{
if (MOBID == "Titan") {
Health = 1000;
MaxHealth = 1000;
}
else
{
Health = 100;
}
MyHealth3D = GetComponentInChildren<TextMesh>().gameObject;
ReDrawHealth();
}
public void DeductHealth()
{
Health = Health - 10;
print("Health: " + Health.ToString());
if (Health <= 0)
{
print("MOB Dead!");
CmdDestroyObject(gameObject);
}
ReDrawHealth();
}
[Command]
void CmdDestroyObject(GameObject ToDestroy)
{
Destroy(ToDestroy);
}
void ReDrawHealth()
{
MyHealth3D.GetComponent<TextMesh>().text = "Health: " + Health.ToString();
}
}
please help i need to release the new update for my game on sunday thanks!