#Nested NOB Bug

124 messages ยท Page 1 of 1 (latest)

celest cargo
#

Here we have a server and 2 clients

the player object has 4 nobs, one for itself and 3 weapon holsters to parent weapons into

the player is spawn on the server

then the player spawns a weapon and holsters it OnServerStart

This results in errors

attached is the unitypackage that produces the issue consisting of 3 scripts and 3 prefabs

celest cargo
#

Still stuck here :/

I need something very basic i believe
the player needs to spawn its starting weapons... like a machine gun on its back and a revolver on the side

I have tried without holster parents, so the weapons straight into the player object... that works , however i need the weapons parented...

also tried these things...

spawning the weapons and parenting one second later
calling spawn on the child nobs of the player on server start
calling spawn on all the nobs on the player when it is instantiated

I wonder if this setup is supported by fishnet, i was able to let a nob spawn another nob and parent it inside of itself for weapon pickups, but it just does not want to work for the player when it has more than one child nob to parent into

Hope this can be fixed or at least can be adviced a better way to handle this situation ^^

echo sky
#

If you parent after network spawning you just need to put a NT on them and check sync parents

celest cargo
#

Succes! , removed the nested network objects and now its parenting just fine, also no coroutine needed wich woud have been rly messedup ๐Ÿ˜„

#

my god , thanks @echo sky

tacit pelicanBOT
#

FirstGearGames received thanks.

echo sky
#

I'm trying to figure out your setup because nested nobs are supported

celest cargo
#

sweet thanks man ^^ , tested a bit further , removing the nested nobs , did get rid of the error but not all the weapons are parented correnty so it seems, some do land in the correct parent others dont :/

celest cargo
echo sky
#

Maybe weapons are arriving in a different spawn packet than player... Doesn't make sense though if they're a child of the player. Client should get both at once

#

If you have a solution you can use it, but if you want me to take a look, try and make a really basic example with cubes and whatnot

celest cargo
#

well i just tried applying the basic test to the real deal and now theyr parenting but im getting networktransform spam :/

#

i can add cubes to the example ive sent if thats what you need ^^, il add some naming things too to make it easyer and comment the code ^^

echo sky
#

I just need a super basic example that doesnt have custom art ect. one that uses unity primatives

celest cargo
#

yup cming up

#

Alright, got the package ready, the code is commented and added some quality of life features to debug ^^
thepackage is as simple as possible, contains

4 prefabs [manager, netmanager, player, weapon]
4 scripts [manager, player, weapon, empty networkbehaviour]
1 scene

No need to build an exe can just hit play in editor ๐Ÿ™‚

#

im on fishnet 2.6

echo sky
#

266 right?

celest cargo
#

i believe so, the one from your website after unlocking it via patreon, downloaded 2 weeks ago

celest cargo
#

got a recording that might help understand whats happening

the component indexes on this player object are shifting, and only when one or more clients connect afterwards

celest cargo
#

Ok so im logging WriteNetworkBehaviour and ReadNetworkBehaviour

#

and the component indexes indeed shift

#

and this is due to collider rollback being removed on the client side ...

#

this makes it so componentIndex does not match between client/server

#

guess it is indeed a bug

my 5cent on the issue...

you might want to opt for a different component index system, I've dealth with this as well, its very hard to maintain and very easy for the user to mess with.

i would suggest, basing it off an ID serialized in the networkbehaviour, this will make nested nb's findable correctly even though some of them might be turned off on either side

for when a user adds an new networkbehaviour (if this becomes a thing) , let the user define an id and send with addcomponent command

hope this helps ^^

#

the collider rollback thing wont fix spawning a player with nested nobs though (this was with nested nb) so im now on to finding out why the server is thiking the nob index is 3 while it should be 2

echo sky
#

ah darn that is a bit of a thing huh

#

using a numeric component system is the more efficient way to do it

#

otherwise youre going to incur a lot of bandwidth costs

celest cargo
#

right def have it numerical

#

the id just needs to not follow the component index, it just needs a fixed index, either set on serialization or user defined (just has to be unique within its own hierarchy)

echo sky
#

It is serialized, which is interesting

#

let me double check

#

Yea, it's serialized.

celest cargo
#

removing the collider rollback does shifts the indexes, havent found where it does that yet but , the result is there ๐Ÿค”

echo sky
#

well that shouldnt be removed anyway tbh, being a NB.

celest cargo
#

yea

echo sky
#

in theory it shouldnt cause issues since server doesnt make calls to it or anything

#

but safer to keep it on

celest cargo
#

roger ๐Ÿ™‚

#

anyways if you want easely reproducible issue with the nobs (not the collider rollback thing) the package is still there , im trying to figure that out atm ^^

echo sky
#

Something really isn't adding up.

#

I validated as host that values are only set during serialization and first start, but not on instantiate

celest cargo
#

the weird thing is

#

with 1 cleint connected it works fine

#

but they change the moment another client connects

#

issue does not happen with just 1 client

#

(i have a splitscreen setup so i dont have to build to test 1+ clients ^^ makes it a lot easyer ๐Ÿ˜„ , the package ive sent also this way but without splitscreen cameras ๐Ÿ˜„ )

echo sky
#

I think I know what's going on.

#

all on one computer, right?

celest cargo
#

correct

echo sky
#

Actually, I was going to say perhaps the second or third client is having them serialized again after removal because of the multiple editors.

#

But that doesn't make sense because it wouldn't serialize an instantiated object, it cannot.

celest cargo
#

ooh

#

i have .. erm

#

this ticked

#

would that redo the indexes?

#

so i have "unhidden" the ComponentIndex variable on the networkobject

#

and i can see it redo the index , whenever a new client connects

#

here we can see nob componentIndex mis match, and also we can see it change as a new client connects, on the owner of the prev connection ...

#

uploading vid .. ^^

echo sky
#

That's not how that field works.

#

ComponentIndex on the nob is the nob component index in nested prefabs

#

It's also serialized and never changed

#

So if you spawn a nob then child it, the component index does not change

celest cargo
#

watch it change ๐Ÿ˜„

#

so i gues serialization is triggering for some reason

#

2 ways the componentIndex change...

#

way nbmr 1

#

way nmr 2

#

one start on networkmanager initialize

#

the other does it when reading incoming client data

celest cargo
#

question @echo sky , should ComponentIndex ever be changed via the "UpdateNetworkBehaviours" method on an instantiated gameobject, so.. not in prefab form?

#

depending on ths answer i think i may have gotten a lot closer to solving my issue ^^

echo sky
#

There is mock code to allow at runtime but it's not turned on

celest cargo
#

this fixes the issue, the nobs now have the same component index and they wont change during play mode

ParseAuthenticated > RegisterAndDespawnSceneObjects, triggers a change on my end , on instantiated gameobjects

and NetworkManager.Initialize aswell

since im in a single editor setup , i gues this is where the issues come from ^^

#

adding the above block (indicated red) fixes all issues

echo sky
#

oh..

#

yeah you know what

#

Let me give you a quick fix

echo sky
#

goto this private void RegisterAndDespawnSceneObjects(Scene s)

#

change to

        private void RegisterAndDespawnSceneObjects(Scene s)
        {
            ListCache<NetworkObject> nobs;
            SceneFN.GetSceneNetworkObjects(s, false, out nobs);

            for (int i = 0; i < nobs.Written; i++)
            {
                NetworkObject nob = nobs.Collection[i];
                if (nob.IsSceneObject)
                    continue;

                base.UpdateNetworkBehavioursForSceneObject(nob, false);
                if (nob.IsNetworked && nob.IsSceneObject && nob.IsNetworked)
                {
                    base.AddToSceneObjects(nob);
                    //Only run if not also server, as this already ran on server.
                    if (!base.NetworkManager.IsServer)
                        nob.gameObject.SetActive(false);
                }
            }

            ListCaches.StoreCache(nobs);
        }```
#

All I did was add this cs if (nob.IsSceneObject) continue;

celest cargo
#

testing ^^

#

i gues this is set true of thi s object is placed in a scene, but thats not the case for me

#

so it goes past the check

#

so the player is spawned into the scene
but RegisterAndDespawnSceneObjects here it takes the already instantiated ones ... i gues from this SceneFN.GetSceneNetworkObjects function
then runs UpdateNetworkBehavioursForSceneObject on it, then triggers the index change

echo sky
#

yeah it will get all nobs in the scene

#

but the registeranddespawn now skips setting if a scene object

celest cargo
#

yup ^^ its my weird setup ๐Ÿ˜„

echo sky
#

ah

#

I get what you're saying

celest cargo
#

yea its never a scene object rly ^^

#

works from the pov where there isnt being tested with those scenes atm ^^ but i am so

echo sky
#

if the object is spawned at runtime, not pre-placed

#

that check I added should stop it.

celest cargo
#

right

#

oh

echo sky
#

also

#

it should be this ๐Ÿ˜ฆ

#
                if (!nob.IsSceneObject)
                    continue;
celest cargo
#

ah ๐Ÿ˜„

echo sky
#

sorry multitasking

celest cargo
#

no worries i know the juggle ๐Ÿ˜„

#

that worked man ^^

#

and that also seems to fix the collider rollback

echo sky
#

sweet

celest cargo
#

what a relief , thanks so mush for the help ^^, review incoming ^^