Hiya,
So I’m trying to display damage text using a text mesh above players that get damaged over the network, however I can only get it to display to the player that has been damaged.
Right now I have a HealthDamageScript attached to the player prefab that looks like this:
...
public class HealthDamageScript : NetworkBehaviour {
...
public Transform damageTextPrefab;
...
public void TakeDamage(int damage)
{
if (!isServer)
{
return;
}
...
RpcDamageText(damage);
...
}
...
[ClientRpc]
void RpcDamageText(int damage)
{
if (isLocalPlayer)
{
Vector3 pos = transform.position;
pos.y += gameObject.transform.localScale.y;
GameObject text = Instantiate(damageTextPrefab, pos, Quaternion.identity).gameObject;
text.GetComponent<TextMesh>().text = "-" + damage;
}
}
}
How would I get the RPC to be sent to all clients rather than only the player that has been damaged?