#Unable to connect two different unity instances on the same machine

11 messages · Page 1 of 1 (latest)

solid blade
#

Hi, I have this really weird bug:

  • When one unity instance acts as a server, the other instance (acting as a client) does not detect or connect to the other instance.
  • I do get success messages for both the server and client instances, which go like "local server/client started on port..."
  • When the client instance tries to spawn a network object, I get "Cannot spawn object because server is not active and predicted spawning is not enabled."
  • When the client instance tries to start another server, I get "Server failed to start. This usually occurs when the specified port is unavailable, be it closed or already in use."

I've tried turning off my (norton360) firewall, and tried both parrelsync clones and build executables.

I just have the default networkmanager with default port/address (7770/localhost).

Unity editor: 2022.3.10f1
Fishnet version: 3.11.18

Does anyone know what could be going on?

pastel portal
#

Hi there, it sounds like it's connecting correctly actually

#

The client cannot spawn objects, the server needs to do that

#

Unless you've specifically setup predicted spawning for the object

solid blade
# pastel portal The client cannot spawn objects, the server needs to do that

Hmm, but when I try to connect the client instance, the server instance doesn't get any new "remote connection started for id ..."

this is the code I use (on the client side) to spawn the network object:

        NetworkObject nob = Instantiate(playerFab);
        InstanceFinder.ServerManager.Spawn(nob, InstanceFinder.ClientManager.Connection);
pastel portal
solid blade
# pastel portal Ok, do you have the full server and client logs from when you try to connect ple...

Here's what I see:

  • First picture is the host (server+client) editor, I start the server and client then spawn my player networkobject
  • Second picture is the client editor, I start it (and it does generate a "remote connection started for id1" on the host editor - my bad, i dont know why I didnt see it before)
  • However on the client editor I am unable to spawn a new player networkobject, nor see the one that should be spawned by the host instance.

Code I use to spawn networkobject:

    public void SpawnPlayer()
    {
        NetworkObject nob = Instantiate(playerFab);
        InstanceFinder.ServerManager.Spawn(nob, InstanceFinder.ClientManager.Connection);
    }

Picture of my player prefab also attached.

pastel portal
solid blade
# pastel portal Ok so it's definitely connecting correctly then. The issue is your code is tryin...

Oh I see, my bad! What's the recommended way to call spawning on the server?

From looking at the PlayerSpawner script it looks like they use a SceneManager_OnClientLoadedStartScenes callback, but I would like to do it on a UI button press instead of whenever the client joins. Also, I would like to spawn the player from a singleton script, but I can't use RPCs on it unless I change it from monobehavior -> networkbehavior.

#

I think a workaround I can do is to use PlayerSpawner to automatically spawn a "Client" network object, then use rpcs inside this to control spawning of the player. Let me try that!

pastel portal