Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved ClientRpc Call not received by Client

Discussion in 'Netcode for GameObjects' started by Janglish, Feb 17, 2023.

  1. Janglish

    Janglish

    Joined:
    Dec 29, 2020
    Posts:
    6
    Hello There,

    i could really need some help with netcode. I try to figure out how everything works on my own. The Example Games provided by Unity are a little bit overwhelming for me.

    I would like to make a loading screen for the players before they enter the game. So i try to disable a canvas GameObject with a NetworkGameObject on it.
    Everthiny works on the host/server Side but on the client side even the Debug.Log("getting Message"); is not being displayed. Why is the rpc-call not going to the client ?

    Any help would be really apprecaited.

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  using Unity.Netcode;
    6. using System;
    7. public class NetworkDataControll : NetworkManager
    8. {
    9.     void Start()
    10.     {
    11.         OnClientConnectedCallback += test;
    12.     }
    13.     private void test(ulong clientId)
    14.     {
    15.        
    16.         if (IsServer)
    17.         {
    18.             if (NetworkManager.Singleton.ConnectedClientsList.Count == 2)
    19.             {
    20.                 Invoke("disableLoadingScreen", 2.0f);
    21.                
    22.             }
    23.         }
    24.     }
    25.     [ClientRpc]
    26.     private void disableLoadingScreenClientRpc()
    27.     {
    28.         Debug.Log("getting Message");
    29.         GetComponentInParent<LoadingSreenManager>().disableLoadingScreen();
    30.     }
    31.     private void disableLoadingScreen()
    32.     {
    33.         disableLoadingScreenClientRpc();
    34.      
    35.     }
    36.  
    37. }
    38.  
     
  2. Janglish

    Janglish

    Joined:
    Dec 29, 2020
    Posts:
    6
    Looks like you cannot make Rpc calls from a Networkmanager Object but you need to do it from a NetworkBehaviour object.
     
    Desine_main and RikuTheFuffs like this.