#Null reference error on joining client for Network Object that is instantiated on server

6 messages · Page 1 of 1 (latest)

viral ruin
#

Hi,

I am attempting to instantiate/spawn a network object / network behaviour and perform some logic on it client side via observers rpc. (1st image)

The 1st thing I need to do is set its parent as when its instantiated over the network it is placed at the root of the scene, which is not what I want as it needs to be attached to its parent (2nd image).

It has a buffer last value set to true so joining clients receive this information and are not out of sync.

The Network object that is being spawned on the network is stored on both server and client as a serialized field via the ability manager. the ability manager is cached on Awake, OnStartClient, and OnStartServer (for testing purposes... I was scratching my head thinking it was a reference issue regarding this... but I guess it isnt)

When it hits the 1st function (SetParent) it works on the host with no issues, but a joining client will receive a null reference exception at the point of log.

This issue does not exist if I move the Network object i.e. Ability to the calling class as a serialized field. The function executes successfully. It also executes successfully if I use a data container i.e. scriptable object for reference. I believe based on tests that this an issue with calling a function on another script for retrieving the instantiated object.

Also, if I see on the client, the original reference to the abilityManager.Abilities[0] disappears strangely. I do not know the cause for this, as Im not destroying any objects in this code block. I am assuming this is the cause for the null reference error.

I am on version 3.6.9 pro, however this was occuring before I updated from 2.3.14 pro

jagged pawn
#

@viral ruin Im taking off for the night but can you try without any conditions to see if maybe something is spawning when it shouldnt be, or perhaps not spawning when it should be.
If that resolves your problem try to hold out a couple days if able as I am resolving these three issues which might be related.
https://github.com/FirstGearGames/FishNet/issues/316
https://github.com/FirstGearGames/FishNet/issues/366
https://github.com/FirstGearGames/FishNet/issues/312
last one could only be a problem if you're using a NT on the object. Also, the last two only seem to occur for child objects.

viral ruin
#

Ok thanks I'll have a look @jagged pawn

deft bronzeBOT
#

FirstGearGames received thanks.

viral ruin
#

@jagged pawn when you say without any conditions, are you referring to thee observer manager default conditions, or my code?

jagged pawn
#

observermanager