It may be me badly understanding how does it work, but shouldn’t the host also receive ClientRPCs, as he’s a client? For example, I want to consistently update health tags on players (those that display above their heads) without having to make two separate functions for clients and the host.
Here are some bits of the code.
InfoTag.cs
public void Refresh()
{
NameText.text = ParentEntity.entityName;
HealthText.text = string.Format("{0} / {1}", ParentEntity.health.ToString(), ParentEntity.maxHealth.ToString());
}
BaseEntity.cs
[ClientRpc]
void RpcUpdateTag()
{
if (Tag != null)
{
Tag.GetComponent<InfoTag>().Refresh();
}
}
[Server]
public virtual void TakeDamage(int damage, Vector3 dir)
{
Push(damage/2, dir);
if (damage >= health)
{
alive = false;
health = 0;
Kill();
}
else
{
health -= damage;
}
RpcUpdateTag();
}