Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Network prefabs not initializing correctly

Discussion in 'Netcode for GameObjects' started by Infirmix, Apr 27, 2023.

  1. Infirmix

    Infirmix

    Joined:
    Nov 13, 2019
    Posts:
    1
    Just migrated project to 2021.3.23f1 with Netcode for GameObjects 1.3.1 and have been getting this warning:
    Code (CSharp):
    1. [Netcode] Runtime Network Prefabs was not empty at initialization time. Network Prefab registrations made before initialization will be replaced by NetworkPrefabsList.
    Tried using the Default list, migrated one and also created a new one but nothing happens.
    I did a build to test localhost and it seemingly doesn't connect neither creates the player prefab and throws the same error.
    Not really sure whats happening since im also kinda new on multiplayer networking and programming in general.
     
  2. c0nfig69

    c0nfig69

    Joined:
    Oct 29, 2021
    Posts:
    5
    For me it worked with migrating. I do not use the playerprefab, I instantiate the prefab and use SpawnAsPlayerObject.
    The problem i occured after updating to 23f1 was that the client was not able to connect anymore. Enambling Remote Connections solved this.
    Of course advanced firewall settings need to allow new unity version as well.
     
  3. Sean2212

    Sean2212

    Joined:
    Jun 9, 2017
    Posts:
    12
    Also getting the same warning with Netcode for GameObjects 1.3.1, with Unity 2022.2.18.

    After StartHost() is called, several objects are being spawned, even though I didn't spawn them. After the host is started those objects are then despawned. EDIT: That was my fault - I added some prefabs to a non-networked scene and didn't remove/disable the network components. :( Warning message still remains.

    I do have a 'player prefab' set in Network Manager.
     
    Last edited: May 11, 2023
  4. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    169
    Actually, I got the same warning, but it doesn't cause any errors or problems.
    Unity : 2021.3.24f1
    Netcode for GameObjects : 1.4.0
     
  5. Kitty-Unity

    Kitty-Unity

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    8
    This bug will be corrected in the 1.4.1 release.
     
    DangerDude_222, Brogan89 and Mj-Kkaya like this.
  6. Edward-dev

    Edward-dev

    Joined:
    Mar 6, 2018
    Posts:
    1
    As a temporary solution, you can:
    1. Clear the Network Prefabs Lists in your Network Manager
    2. Create a script to manually add your prefabs at the beginning of the game.
    Example:
    Code (CSharp):
    1. public class AppStartup : MonoBehaviour
    2. {
    3.     [SerializeField] private NetworkPrefabsList _networkPrefabsList;
    4.  
    5.     private void Start()
    6.     {
    7.         RegisterNetworkPrefabs();
    8.     }
    9.  
    10.     private void RegisterNetworkPrefabs()
    11.     {
    12.         var prefabs = _networkPrefabsList.PrefabList.Select(x => x.Prefab);
    13.         foreach (var prefab in prefabs)
    14.         {
    15.             NetworkManager.Singleton.AddNetworkPrefab(prefab);
    16.         }
    17.     }
    18. }
    This works for me.

    Unity: 2022.2.5f1
    Netcode for GameObjects: 1.4.0
     
    Last edited: May 23, 2023
    FrozenPeak likes this.
  7. louistbmtl

    louistbmtl

    Joined:
    Aug 30, 2021
    Posts:
    6
    Any ETA on that update ? Thanks
     
    jereroy likes this.
  8. louistbmtl

    louistbmtl

    Joined:
    Aug 30, 2021
    Posts:
    6
    This is working for me as a temp fix, thanks a lot for this !!!
     
    jereroy likes this.
  9. Beatdones

    Beatdones

    Joined:
    Mar 28, 2020
    Posts:
    6
    I tried what Edward-dev mentions, but didn't get good results. All my client users do not react to my inputs.
    Only the Host works for me.

    Code (CSharp):
    1. using Unity.Netcode;
    2. using UnityEngine;
    3.  
    4. public class PlayerNetwork : NetworkBehaviour
    5. {
    6.  
    7.     private void Update()
    8.     {
    9.         if (!IsOwner) return;
    10.  
    11.         Vector3 moveDir = new Vector3(0, 0, 0);
    12.  
    13.         if (Input.GetKey(KeyCode.W)) moveDir.z = +1f;
    14.         if (Input.GetKey(KeyCode.S)) moveDir.z = -1f;
    15.         if (Input.GetKey(KeyCode.A)) moveDir.x = -1f;
    16.         if (Input.GetKey(KeyCode.D)) moveDir.x = +1f;
    17.  
    18.         float moveSpeed = 3f;
    19.         transform.position += moveDir * moveSpeed * Time.deltaTime;
    20.     }
    21.  
    22. }
    Thanks for the help.
     
  10. DangerDude_222

    DangerDude_222

    Joined:
    Mar 10, 2021
    Posts:
    2
    not for me, I still have this error message...:(
     
    cadedempsey1 likes this.
  11. cadedempsey1

    cadedempsey1

    Joined:
    Nov 26, 2019
    Posts:
    1
    me also
     
  12. FrozenPeak

    FrozenPeak

    Joined:
    Jun 8, 2023
    Posts:
    1
    The temporary solution also works for me. Thanks.
    I have Unity: 2021.3.26f1, Netcode: 1.4.0.
     
  13. neviovalsa

    neviovalsa

    Joined:
    Jun 24, 2019
    Posts:
    30
  14. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    342
    Is it safe to upgrade to 1.5.1 in 2021.3.23f1?
     
  15. MidniteOil

    MidniteOil

    Joined:
    Sep 25, 2019
    Posts:
    342
    Nevermind, read the readme.

    Another question, I thought I could just import the update with Package manager using the git url but am getting this error:

    [Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git]:
    [https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git] does not point to a valid package. No package manifest was found. [NotFound]

    How do you typically pull these updates in? The Unity Registry is only showing up to 1.3.1.
     
  16. c0nfig69

    c0nfig69

    Joined:
    Oct 29, 2021
    Posts:
    5
    add package by name; com.unity.netcode.gameobjects; 1.5.1
    But i woud recomend updating also unity to newest 2021
     
  17. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    169
    This warning disappears at Unity 2022.3.4f1 and Netcode For GameObjects 1.5.1