#Multiplayer Struggles with Unity 6

1 messages · Page 1 of 1 (latest)

stark canopy
#

I am trying out the new widget system for unity NGO.
but there is no widget for transfering scenes when all players have conected to a lobby. I tried to do this myself but with no success. Is there someone who could help me with this?
Heres my setup:

using UnityEngine;

public class NetworkUI : MonoBehaviour 
{ 
    public void OnStartGamePressed() 
    { 
        if (!NetworkManager.Singleton.IsHost) return; 
        NetworkManager.Singleton.SceneManager.LoadScene("GameScene", 
            UnityEngine.SceneManagement.LoadSceneMode.Single); 
    } 
}```

And i use the widgets for creating a lobby, joining a lobby by code and some other visual ones.
Ive added the code above onto a button, for when the players have connected but i found out that this doesnt work. any tips or help?
Thanks in advance
edgy spire
#

That code isn't loading the game scene?

stark canopy
#

nope, and it could be a config setting but im not sure,

#

it is registerd here

#

its suposed to be a prototype, so nothing fancy needed. But im not sure what im doing wrong here

edgy spire
#

Scene Management enabled on the Network Manager?

stark canopy
#

yep

edgy spire
#

No errors or warnings in console?

stark canopy
#

nope, just a popup that says joined session xxxxxxxxxxxxxxx

#

but no scene transfer

edgy spire
#

Do you happen to be calling this code before the network has a chance to start?

#

In that case IsHost would be false and your code wouldn't run

stark canopy
#

not sure, i use the widgets and ive not really used those before, so idk if there is a widget that needs to be pressed before starting up or something?

#

or if create session starts it up

edgy spire
#

Creating a session can be configured to also start up NGO. I don't know for sure, but I would guess that's what widgets does.

#

But yeah, it just sounds like IsHost is returning false which likely means the NetworkManager hasn't started up. I would just put in some Debug.Logs to confirm.

stark canopy
#

Yeah it is false. Anything I can do to start it up before transferring scenes?

edgy spire
#

Are you able to send the code for the widget you're using to start your session?

#

Sorry - I have not really used Widgets.

bleak juniper
#

the widgets don't swap scenes automatically

#

there is an event you can subscribe to from it though

stark canopy
#

Me neither, and I can’t seem to find the code for the widgets that’s why I came here

edgy spire
#

Yeah I think his issue is more that the session is not starting up NGO. Is there a widget that does that with Direct Network or Relay?

bleak juniper
#

They use Relay by default. There is a WidgetConfiguration scriptable object

#

the widget source code is locked in the package folders. They are not very customizable currently

#

Normally I only use the QuickJoin/Leave widgets. For everything else I'll code it manually

stark canopy
#

alright, i guess ill try some more things. Just not sure how to start up NGO with the newer version

stark canopy
#

the problem is that i cant seem to set the player who created the lobby to an host, if 2 players are in the lobby, both are a client.

stark canopy
#
    {
        if (NetworkManager.Singleton.IsListening) return;

        Debug.Log("Starting up as host");
        NetworkManager.Singleton.StartHost();

        await Task.Yield();
    }```

i have now tried this and im not sure what im doing wrong here, it still starts up as a client
bleak juniper
bleak juniper
stark canopy
#

well thats what i tried but i wont connect to another scene that way, im just trying to get 2 players into a lobby, and have them both transfer scenes

bleak juniper
#

The session is the lobby. Once they have joined they are in the same Lobby. You can check the session viewer in the editor to double check that.

stark canopy
#

i just found the problem i think, the connection type was set to distributed authority instead of relay, and it connects to my other scene now

bleak juniper
stark canopy
#

well thanks a lot haha, spent my whole 8 hours yesterday to switch 1 button, gotta love game development

#

i must say i do like unity's new multiplayer integration, its just getting used to

bleak juniper
#

It's great to quickly get started prototyping. But always be ready to rip out those widgets when needed.

stark canopy
#

Finally got it all working, had some problems with player spawning because of transferring the scene, so i did that manually instead of the spawner the network transform has, thanks a lot guys!

bleak juniper
stark canopy
#

yeah exactly, if i used it in the network manager, it spawned while i was still in the menu, and that amde sure everything was unclickable.