TinyBirdNet-Unity icon indicating copy to clipboard operation
TinyBirdNet-Unity copied to clipboard

When connecting to a server, the registered scene prefabs remain disabled (plus spawn-in questions)

Open SoftwareGuy opened this issue 7 years ago • 1 comments

This is a two-part issue ticket. Let's start with the puzzler: In my test scene, I have 2 prefabs that are called "Floor" and "Game". "Game" contains management scripts that the controller I'm porting to TinyBirdNet. Each gameobject has an attached TinyNetIdentity and the Asset GUID is correctly set (as part of the prefab saving process). For example, here's what the "Game" gameobject has attached:

image And I have them in the scene, enabled as usual: image

However, upon connecting to the server, they get disabled and never get re-enabled (as in, they get grayed out in the inspector). I don't know what's going on, but I have a Network Manager gameobject that contains a very barebones script as follows:

using UnityEngine;
using TinyBirdNet;

public class ExperimentalTinyBirdNetManager : TinyNetGameManager
{
    string hostAddress = "127.0.0.1";
    int hostPort = 31337;

    // Use this for initialization
    private void Start()
    {
        print("ExperimentalTinyBirdNetManager started up");

        instance.SetPort(hostPort);
        instance.StartServer();

        instance.StartClient();
        instance.ClientConnectTo(hostAddress, hostPort);
    }

    public override void ClientConnectTo(string hostAddress, int hostPort)
    {
        base.ClientConnectTo(hostAddress, hostPort);
    }

    public void OnClientReady()
    {        
        print("OnClientReady fired!!");
    }
}

Part 2 of the issue ticket: What would be the TinyBirdNet Equivalent of this UNET code?

      public override void OnServerAddPlayer(NetworkConnection conn)
        {
            var spawnPosition = Vector3.right * conn.connectionId;
            var player = GameObject.Instantiate(playerPrefab, spawnPosition, Quaternion.identity) as GameObject;
            NetworkServer.AddPlayerForConnection(conn, player);
        }

As you can probably tell, this code is called if you issue a server-side AddPlayer command on the Server side. It would spawn a player object and assign the connection as the owner of that GameObject. I see you either haven't implemented such functions or I'm looking in the wrong place. I cannot use TinyNetPlayerController as the kit I'm using would break and it already uses a lot of RPCs and whatnot for server <-> client communication.

If it's unimplemented then I am going to have to stop porting the kit my project uses to TinyBirdNet because this is a show-stopper.

Sidenote: This looks like a showstopper... image

SoftwareGuy avatar Nov 01 '18 08:11 SoftwareGuy

I'm in another country without a computer, but I will ever in contact as soon as I can!

On Thu, Nov 1, 2018, 05:57 Coburn <[email protected] wrote:

This is a two-part issue ticket. Let's start with the puzzler: In my test scene, I have 2 prefabs that are called "Floor" and "Game". "Game" contains management scripts that the controller I'm porting to TinyBirdNet. Each gameobject has an attached TinyNetIdentity and the Asset GUID is correctly set (as part of the prefab saving process). For example, here's what the "Game" gameobject has attached:

[image: image] https://user-images.githubusercontent.com/1762115/47841374-1e56ae00-de05-11e8-83ce-a06ce709f4b9.png And I have them in the scene, enabled as usual: [image: image] https://user-images.githubusercontent.com/1762115/47841402-33cbd800-de05-11e8-93e2-6d7e85f68c39.png

However, upon connecting to the server, they get disabled and never get re-enabled (as in, they get grayed out in the inspector). I don't know what's going on, but I have a Network Manager gameobject that contains a very barebones script as follows:

using UnityEngine;using TinyBirdNet; public class ExperimentalTinyBirdNetManager : TinyNetGameManager { string hostAddress = "127.0.0.1"; int hostPort = 31337;

// Use this for initialization
private void Start()
{
    print("ExperimentalTinyBirdNetManager started up");

    instance.SetPort(hostPort);
    instance.StartServer();

    instance.StartClient();
    instance.ClientConnectTo(hostAddress, hostPort);
}

public override void ClientConnectTo(string hostAddress, int hostPort)
{
    base.ClientConnectTo(hostAddress, hostPort);
}

public void OnClientReady()
{
    print("OnClientReady fired!!");
}

}

Part 2 of the issue ticket: What would be the TinyBirdNet Equivalent of this UNET code?

  public override void OnServerAddPlayer(NetworkConnection conn)
    {
        var spawnPosition = Vector3.right * conn.connectionId;
        var player = GameObject.Instantiate(playerPrefab, spawnPosition, Quaternion.identity) as GameObject;
        NetworkServer.AddPlayerForConnection(conn, player);
    }

As you can probably tell, this code is called if you issue a server-side AddPlayer command on the Server side. It would spawn a player object and assign the connection as the owner of that GameObject. I see you either haven't implemented such functions or I'm looking in the wrong place. I cannot use TinyNetPlayerController as the kit I'm using would break and it already uses a lot of RPCs and whatnot for server <-> client communication.

If it's unimplemented then I am going to have to stop porting the kit my project uses to TinyBirdNet because this is a show-stopper.

Sidenote: This looks like a showstopper... [image: image] https://user-images.githubusercontent.com/1762115/47842204-bc4b7800-de07-11e8-89b5-7ee24ebdf60e.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Saishy/TinyBirdNet-Unity/issues/11, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6zzMzA1vIrMb_5JN-zS4UkrIvTK2vNks5uqrdjgaJpZM4YGBGs .

Saishy avatar Nov 01 '18 20:11 Saishy