Open Rob-Kilgore opened 5 days ago
I was not able to reproduce this. Please provide a project doing so and this will be looked into. https://fish-networking.gitbook.io/docs/manual/guides/creating-bug-reports#guidelines
Here's a unitypackage with what I used to reproduce this issue. The project had only these files & a stock FishNet installation. Note the difference between setting the toSpawn parameter of the Object Spawner component in OnlineScene to NestedPrefab or NormalPrefab. PrefabBugReport.zip
This is happening to me too, with this same prefab ID.
I'm just using the NetworkManager and dropping a prefab on to the "Player Prefab" field.
The po
here has a single prefab with an ID of 0. There are a couple of calls to this where the code is looking for id of 0 and that works just fine. Then there's a call looking for ID 65535, which doesn't exist.
PrefabObjects po = NetworkManager.GetPrefabObjects<PrefabObjects>(nob.SpawnableCollectionId, false);
tpf = nob.GetTransformChanges(po.GetObject(asServer: true, nob.PrefabId)
I also tried creating my own spawnables SO, but that didn't resolve it. Strangely, I had it working with a different spawn prefab.
Edit: The original prefab I had working no longer works. Same error. I created plain sphere object, slapped a network transform on there and set that to the player prefab and that works. Of course, it doesn't do anything but the client at least starts.
I'm using v4.4.5R
@Rob-Kilgore I think I figured it out. I had a prefab like this RootObject
. I added some debugging to the FishNet code where it was breaking and discovered that 65535 is just public const int UNSET_PREFABID_VALUE = ushort.MaxValue;
when the PrefabId
wasn't set. I logged the name of the game objects to find that the problem was on Child
. Once I removed the NetworkObject
component from Child
(see Child2
). It looks like the problem went away.
classDiagram
RootObject <|-- Child
RootObject2 <|-- Child2
class RootObject{
NetworkObject
}
class Child{
NetworkObject
NetworkAnimator
NetworkTransform
}
class RootObject2{
NetworkObject
}
class Child2{
NetworkAnimator
NetworkTransform
}
This prevents me from upgrading to the latest version, breaks my game.
General Unity version: 2022.3.30f1 Fish-Networking version: 4.4.5 Pro Discord link: https://discord.com/channels/424284635074134018/1279073515139502112/1279073515139502112 (Discord Username is markclark, please let me know if I can provide further info)
Description When spawning a prefab with nested network objects, I get 2 exceptions with messages "PrefabId 65535 is out of range." and "NullReferenceException: Object reference not set to an instance of an object".
I have reproduced this with a function as simple as the following in OnStartServer on a script in my online scene where toSpawn is my nested network object:
If I switch the prefab to a flat Game Object (No nested network objects), then there is no exception
Replication Steps to reproduce the behavior:
Expected behavior The object should spawn without error
Actual behavior The object causes 2 exceptions on spawn
Screenshots stacktrace2.txt stacktrace1.txt