I’m making a multiplayer card game on unity and I’m trying to implement the networking aspect into the current build I have. However, I am bumping into a problem I have no past experience in dealing with. Whenever I spawn my player prefab, I get a null reference exception that seems to be due to an “OnParentChange” event. This error is triggered after netcode initialization when the game is transitioning from lobby to the relay connection. Additionally if a client joins, it’ll stay connected for a few seconds before the connection times out, which I believe is due to this issue as I used the exact same code for the relay and the lobby in another Unity project where the overall goal was just spawning a circle for each player and each player being able to move it. With this in mind, I think there might be some error with the player prefab. The prefab is essentially a player manager, handling most of the actions for the player. It has a network object as well as a “player manager” script that assigns itself variables active in the scene when the player prefab spawns. Additionally, the prefab also has children in the form of the player’s actual deck (supposed to be a trading card game). This consists of an empty game object that has its own children which are essentially the cards. Each card has a card script, a network object script, and a client network transform script. I’m away from my computer at this moment but I can send images/scripts later. I just keep drawing up blanks as to how to fix this issue. Anyone have any insight as to what might be the root of these problems.
Post the relevant sections of the code, don’t try to transcribe it because it cannot be debugged. ![]()
Also if you search the forum for NullReferenceException you’ll find more than one post by Kurt Dekker explaining how to solve these.
Hey, just wanted to respond because I found the solution to this. The children of my player prefab had a network transform. Once I took that out, it fixed the problem.