Search Unity

Host isn't receiving ClientRPCs

Discussion in 'Multiplayer' started by TFlippy, Jul 4, 2015.

  1. TFlippy

    TFlippy

    Joined:
    Nov 12, 2014
    Posts:
    27
    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
    Code (CSharp):
    1.  
    2.     public void Refresh()
    3.     {
    4.         NameText.text = ParentEntity.entityName;
    5.         HealthText.text = string.Format("{0} / {1}", ParentEntity.health.ToString(), ParentEntity.maxHealth.ToString());
    6.     }
    7.  
    BaseEntity.cs
    Code (CSharp):
    1.  
    2.     [ClientRpc]
    3.     void RpcUpdateTag()
    4.     {
    5.         if (Tag != null)
    6.         {
    7.             Tag.GetComponent<InfoTag>().Refresh();
    8.         }
    9.     }
    10.  
    11.     [Server]
    12.     public virtual void TakeDamage(int damage, Vector3 dir)
    13.     {
    14.         Push(damage/2, dir);
    15.        
    16.         if (damage >= health)
    17.         {
    18.             alive = false;
    19.             health = 0;
    20.  
    21.             Kill();
    22.         }
    23.         else
    24.         {
    25.             health -= damage;
    26.         }
    27.  
    28.         RpcUpdateTag();
    29.     }
    30.  
     
  2. Kristonitas

    Kristonitas

    Joined:
    Jan 16, 2013
    Posts:
    9
    This is fixed, in newest patch versions at least. If you already us newest patch version, then probably submit a bug report.