#I am not creating a new scene I am just

1 messages · Page 1 of 1 (latest)

rotund tartan
#

"loading the hosts scene on the client" it sounds like your network manager on the client is doing the loading of the scene, not the network manager attached to the host.

gleaming moth
#

If I don't load the scene locally nothing happens and the player stays in the lobby scene

rotund tartan
#

well there is where the issue is. you can't load the scene from the client. you may have to add an isServer tag inside the onclientconnected override

#

you follow what I'm saying?

gleaming moth
#

Kinda I think

#

So if I want to load into the host scene what do I do

#

I can send you the code for loading into the game if you want?

#

btw it worked before I had urp and seperated the enviroment and the interior

rotund tartan
#

you can send it or whatever.

#

this is my uimanager

#

this is where I connect.

gleaming moth
#
using System.Collections;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class NetworkManagerUI : NetworkBehaviour
{
    [SerializeField] private Button HostButton;
    [SerializeField] private Button JoinButton;
    [SerializeField] private GameObject LobbyUI;
    [SerializeField] private InputField JoinCodeBox;
    [SerializeField] private GameObject Relay;

    private void Awake()
    {
        HostButton.onClick.AddListener(() => 
        {
            Relay.GetComponent<Relay>().CreateRelay();
            //NetworkManager.SceneManager.LoadScene("TardisDimension", LoadSceneMode.Single);
            //NetworkManager.SceneManager.LoadScene("Map1", LoadSceneMode.Additive);
            SceneManager.LoadScene("TardisDimension", LoadSceneMode.Single);
            SceneManager.LoadScene("Map1", LoadSceneMode.Additive);
        });
        JoinButton.onClick.AddListener(() => 
        {
            Relay.GetComponent<Relay>().JoinRelay(JoinCodeBox.text);
            NetworkManager.SceneManager.LoadScene("TardisDimension", LoadSceneMode.Single);
            NetworkManager.SceneManager.LoadScene("Map1", LoadSceneMode.Additive);
        });
    }
}
#

I have tried loading it through network manager

rotund tartan
#

you need to use the singleton of scenemanager.

#

once second let me read

#

so this is not the networkmanager of the host.

#

this is the networkmanager of the client.

#

you need to have an onclient connectedcallback

#

and spawn the player / load the scene via the connected callback.

#

in order to do that you need to:

#

create an empty object called something like networkplayersmanager

#

add a script

#

and then inside void start

#

add NetworkManager.Singleton.OnClientConnectedCallback += (obj) = > { ... YOUR CODE HERE}

#

the obj will be the client's ID

#

the host will also have a client ID, too.

#

and the host will load into the scene the exact same way as the client.

#

notice the isServer tag.

#

you following?

#

also you don't need to serialize the buttons.

#

those only exist on the client as triggers.

#

you'll probably need to add a "network object" component to the networkplayersmanager

gleaming moth
#

Okay

#

I think multiplayer might be a bit advanced

#

for me

rotund tartan
#

it isn't that hard. what is hard is the rigidbody crap and movement via netcode's physics stack.

#

it's stupid.

#

getting players into a scene is just the beginning.

gleaming moth
#

Exactly

#

I am going to work on getting better at sp then learn mp later

rotund tartan
#

just a word of caution. you will have to re-think everything when it comes to networking and movement and stuff.

#

I would try to make a simple game and slowly introduce stuff.

#

but still make it multiplayer

#

start with 2D

gleaming moth
#

The game worked great and had no bugs before I split the game into multiple scenes.

#

And just loading the scene on host and client with normal scenemanager worked

rotund tartan
#

they have example code called boss room