Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
#Scene Manager
330 messages · Page 1 of 1 (latest)
each of my player will call the LoadSceneWithLoadingScreenCoroutine method which makes them load into the specified scene, which in this instance will be the gameplay scene
my problem is that i tried to manually add their connection to the scene they are loading into, but im not sure if a client can do that himself
since fishnet apperantly also has callbacks for then a scene starts loading, the loading progress and when it finishes, i want to convert this script to use fishnet's scene management as well
could anyone help me do that?
i would still like my "Loading" scene to appear whenever the scene is loading
also to mention my "Bootstrap" scene is always active as the main scene, so if im loading another scene it'll have to be an additive
Hi there, I think if you have a nice setup for loading the scene already then just keep that. On the client side once the scene is loaded fully just send a broadcast to the server telling it that it's loaded and use the AddConnectionToScenes method
would i need to pass in the connection as well or should this work?
What object is that on?
LocalConnection wouldn't work
You would either use Owner, or the connection of the caller
so my scene manager is in the bootstrap which is always active, and it also has the network object
I wouldn't recommend that
I'd recommend using a broadcast instad
NetworkObjects in the bootstrap scene can be messy
so make it a mono behaviour?
could you link me the documentation for that
because im not sure on how to do it
sorry i read through it but im still a bit confused, could you try and explain how to do it?
but if i do it once i'll know how to do it in the future
Which part is the problem at, I can try to explain that part
In summary, on the server you listen for the broadcast the client will send.
InstanceFinder.ServerManager.RegisterBroadcast can be used for listening
so i would send the broadcast from the ClientManager?
On the client you send the broadcast with: InstanceFinder.ClientManager.Broadcast(msg);
Right
can i have all of this in 1 script
or would i have to make a seperate one for the listening
yep absolutely
That looks good
It's good to
like you do with actions
Best to do it, even though the object may be part of the bootstrap
seems to work
thanks
and now i understand broadcasts as well
gonna make a chat system in a minute
one more question though
this is about something else
but i just realised its also broken
when spawning my player it doesnt give him the ownership of that network object
It does in the Spawn call though
for some reason when i spawn in as a player
it turns the script off for me
suggesting i dont have the owner
even though i should
if you log in the first if block, does it ever print?
oh wait
nevermind
it doesnt even spawn the player
that was just the old prefab i left in the scene
ah I see
I guess first of all, do you have a Scene Observer Condition in your ObserverManager?
Ah ok, you need to add it there
what does that do
it prevents the server trying to tell clients about objects they don't yet have
okay i added it
but its still not spawning my player for some reason
this is the new scene manager
https://hastebin.com/share/fiqayifode.csharp
and this is the player spawner
i start the connection in the lobby
and then the scene with the player spawner is loaded
OnSpawnServer isn't being called
Does the Debug.Log($"[Server] Added client {conn.ClientId} to scene {msg.SceneName}"); log get printed on the server?
Is the Scene scene = UnitySceneManager.GetSceneByName(msg.SceneName); correct?
Can you like print the handle from that and also print the handle in the PlayerSpawner
yup its correct
OnSpawnServer isn't called
i put a debug log there
right, we need to find out why, hence the scene handle checks
did you try printing it in Awake and the broadcast method?
sorry where
In awake on the player spawner
And on the line after you add the connection to the scene
just a Debug.Log right?
wait
it was because of this
i had both of these ticked off
do i just need the IsNetworked?
No problem, glad to hear it's working
i tried destroying the player prefab from the scene
but its not destroying it
like this one
because i dont want to manually delete it every time
do i have to call despawn?
and in the OnSpawnServer
like this
Why is it there?
this is just when im testing
i wanna be able to see him in the scene
obviously when im going to build the game im going to delete him
its just to make testing easier
Interesting that the destroy doesn't work
I thought it would, I may have to look into that tomorrow
wait it does
but it keeps giving me this after
no problem
Ok, looks like you'll never to not reference the object at all if you do destroy it, then it should be fine.
sorry what do you mean by that
i think its because its already registered in fishnet as a network object in that scene
Do you have a full stack trace for that error?
let me check when i hop on my pc
I just tried with a full network object and network behaviour that destroys itself in awake and doesn't have any errors.
So I suspect something else is referencing the script or object in some way
MissingReferenceException: The object of type 'NetworkObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
FishNet.Object.NetworkObject.SetIsNestedThroughTraversal () (at Assets/Plugins/FishNet/Runtime/Object/NetworkObject.cs:1332)
FishNet.Managing.Server.ServerObjects.InitializeRootNetworkObjects (System.Collections.Generic.List`1[T] nobs) (at Assets/Plugins/FishNet/Runtime/Managing/Server/Object/ServerObjects.cs:382)
FishNet.Managing.Server.ServerObjects.SetupSceneObjects (System.Collections.Generic.List`1[T] sceneNobs) (at Assets/Plugins/FishNet/Runtime/Managing/Server/Object/ServerObjects.cs:443)
FishNet.Managing.Server.ServerObjects.IterateLoadedScenes (System.Boolean ignoreFrameRestriction) (at Assets/Plugins/FishNet/Runtime/Managing/Server/Object/ServerObjects.cs:343)
FishNet.Managing.Server.ServerObjects.TimeManager_OnUpdate () (at Assets/Plugins/FishNet/Runtime/Managing/Server/Object/ServerObjects.cs:110)
FishNet.Managing.Timing.TimeManager.TickUpdate () (at Assets/Plugins/FishNet/Runtime/Managing/Timing/TimeManager.cs:365)
FishNet.Transporting.NetworkReaderLoop.Update () (at Assets/Plugins/FishNet/Runtime/Transporting/NetworkReaderLoop.cs:28)
its coming from the network manager
anything yet?
Oh, thanks for the reminder, I forgot about this today 😅
Hmm, still no luck replicating it unfortunately. The code I have on the object is simply: Destroy(gameObject); in Awake
have u tried starting the connection in a different scene
then switching to a new scene where this player spawner is
and in that scene calling the Destroy in Awake?
I'll try to test that when I get a chance to
thanks
i tried everything
still getting the error
i added a cube and slapped a network object on it
and tried destroying it
and got the error
that was after i stopped the game
how do i check
In the FishNet/package.json file
Ok, best to try the new version then
do i just update?
or do i need to remove the old one first
and will this break things
i updated it
still getting the error
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
now this isnt even hiding the player prefab
before it was hiding it
tf
Ok, what exact steps should I follow to be able to replicate it?
No problem, thank you 🙏
im not sure, all im doing is starting the connection in another scene, then switching to the one with this script
and in that script trying to destroy the network object prefab of the player (the one in the scene)
in awake
and my console starts spamming with this
Ah ok, that works, I can replicate it now
try to destroy a prefab which is in the scene which has a network object on it
in Awake
but start the connection in a different scene
after i upgraded the version its also not hiding the prefab
hopefully
any luck?
I don't think there will be a quick fix, most likely a bug report will need to be made
I'll try to do that today
thanks
Okay, I've opened an issue for it here: https://github.com/FirstGearGames/FishNet/issues/922
GitHub
General Unity version: 6000.0.34 Fish-Networking version: 4.6.9 Discord link: #1379896094414340289 message Description When destroying a N...
thank you so much
i appreciate it a lot
do you know in the meanwhile how i can at least hide the player prefab?
a work around for now
because when i updated the fishnet version its not even setting the object inactive
Does disabling it in OnStartClient work?
Destroying it from OnStartClient should actually work well
let me test when u get home
can you tell me how to load sceen from ab?
sorry?
the loby example is load buidin sceen,i want from AssetBundle
im not sure
im not using fishnet to load the scenes
i made everything from scratch
same with my lobby system
your lobby system?
fishnet pro has a example lobby and world
do you see it?
have you read it?
im not using that
i made my own lobby system
and scene manager
im not using fishnet scene manager
im just adding connections to the scenes
im not sure im the right person to ask man
I think you should create a new post for that as it's not related to this one
that's cool. i read it hardly.
ok, i dont even konw the broadcast and Observer label has different? or they are same thing?
The docs should go over those two, otherwise if you have specific questions about them you can definitely ask in a new #1020320683508650025 post or in #🧽help and people will likely be more than happy to assist 🙂
i can try and help you best i can but im still not sure i have what you need
i have one ,how to load screen from assetbundle?
yeah then you're going to have to start a new help post in #🧽help
im not using asset bundles
i want make lobby and world ,but the sceen is form assetbundles.
the example is from buildin.
i am working webgl small game on wechat in china.
@placid dune
only the host can ever get past this statement
the other clients get stuck here loading into the scene
why is that?
the clients have fully started the connection here by now
so their client manager should be started no?
I would have thought so. Have you logged the state of ClientManager.Started?
its never started
only the player hosting which started a server first can get past this check
all the other clients get stuck here and the rest of the code doesnt continue
Does the ClientManager.Connection print a valid connection?
let me check in a minute
where should i check that
should i check it here?
this is where the connection for the client is Started
Ah that's where you are calling it
That's likely too soon
Best to use the authentication event
whats that?
im using these ones as of right now
For performing actions once the client is ready it's better to use the ClientManager.OnAuthenticated event: https://firstgeargames.com/FishNet/api/api/FishNet.Managing.Client.ClientManager.html#FishNet_Managing_Client_ClientManager_OnAuthenticated
and thats when he's connected as well?
Once he's connected and authenticated
is there a better event for when the server has started?
because this is how im checking if the server started to then start the client
The server one should be fine I believe
Since the server doesn't need to authenticate itself
okay
Looks good to me
for some reason it still doesnt seem to be working
i'll show you where it stops
so when im hosting the game and im the server
it'll work and load me in perfectly
but all the other clients will get stuck here
this is the scene manager which gets stuck on line 72
and this is the connection manager
https://hastebin.com/share/ewahetazet.csharp
wait is it because of these booleans in scene manager?
will the OnClientSceneLoaded only run on the server?
that might explain why its getting stuck there
yup
@placid dune
the problem is here
this only sets true for the host(server)
any idea how to fix it?
i need another way to check if the connection has been either removed or added
and then continue
because the broadcasts will only run on the server
thats why it never sets those bools on the clients
let me phrase it differently
i need the broadcast to return to the client that called it
the boolean to set it true
that its done
any ideas?
Ok, you could send the broadcast to the client that calls it
smart
im going to test it out now
look correct?
that looks correct to me
could you take a quick look please?
because once again if im not the host/server, it'll get stuck here
the broadcast that i send back is not setting the bool to true
Can't really see why that may be. You may need to add debug logs to each step to see where it is failing
these aren't being called
for some reason
but im sending a broadcast to the server?
the clients aren't recieving the returning broadcast
Ok so if the clients aren't receiving a broadcast it could either mean they aren't yet authenticated (unlikely here), they didn't yet subscribe to receive the broadcast, or the server didn't send it to the correct connection
right
so it'll sound dumb
i kept forgetting to upload the build with the changes to steam
so on my laptop i had the old version instead of the new one
it works perfectly
my bad
Ah ok 😁
That's happened to me before too