示例#1
0
    private void ApprovalCheck(byte[] connectionData, ulong clientId, MLAPI.NetworkManager.ConnectionApprovedDelegate callback)
    {
        bool approve            = true;
        bool createPlayerObject = true;

        ulong?prefabHash = NetworkSpawnManager.GetPrefabHashFromGenerator("MyPrefab");

        callback(createPlayerObject, prefabHash, approve, Vector3.zero, Quaternion.identity);
    }
    private void ApprovalCheck(byte[] connectionData, ulong clientId, MLAPI.NetworkManager.ConnectionApprovedDelegate callback)
    {
        print("approving...");
        // bool approve = true;
        // bool createPlayerObject = false;

        var payload = System.Text.Encoding.UTF8.GetString(connectionData);

        print($"connected {payload} \nClient: {clientId}");

        ulong?prefabHash = NetworkSpawnManager.GetPrefabHashFromGenerator("MyPrefab");
        //callback(createPlayerObject, prefabHash, approve, Vector3.zero, Quaternion.identity);
    }
示例#3
0
    private void ApprovalCheck(byte[] connectionData, ulong clientId, MLAPI.NetworkManager.ConnectionApprovedDelegate callback)
    {
        Debug.Log("Client " + clientId + " is joining server with password: "******"MyPrefabHashGenerator" with the name of a prefab added to the NetworkPrefabs field of your NetworkManager object in the scene
        ulong?prefabHash = NetworkSpawnManager.GetPrefabHashFromGenerator("Player_Client");

        ////If approve is true, the connection gets added. If it's false. The client gets disconnected
        callback(createPlayerObject, prefabHash, approve, new Vector3(0, 1, 0), new Quaternion());
    }
    private void ApprovalCheck(byte[] connectionData, ulong clientId, MLAPI.NetworkManager.ConnectionApprovedDelegate callback)
    {
        //Your logic here
        bool approve            = true;
        bool createPlayerObject = true;

        // The prefab hash. Use null to use the default player prefab
        // If using this hash, replace "MyPrefabHashGenerator" with the name wof a prefab added to the NetworkPrefabs field of your NetworkManager object in the scene
        ulong?prefabHashKid   = NetworkSpawnManager.GetPrefabHashFromGenerator("KID");
        ulong?prefabHashSnail = NetworkSpawnManager.GetPrefabHashFromGenerator("SNAIL");

        //If approve is true, the connection gets added. If it's false. The client gets disconnected
        if (counter % 2 == 1)
        {
            callback(createPlayerObject, prefabHashSnail, approve, snailSpawn[Random.Range(0, snailSpawn.Length)].position, quaternion.identity);
        }
        else
        {
            callback(createPlayerObject, prefabHashKid, approve, kidSpawn[Random.Range(0, kidSpawn.Length)].position, quaternion.identity);
        }

        counter++;
    }
示例#5
0
        private static void ClientConnectionApproval(byte[] connectionData, ulong clientId, NetworkManager.ConnectionApprovedDelegate callback)
        {
            ulong?prefabHash = NetworkSpawnManager.GetPrefabHashFromGenerator(PlayerPrefabHashString);

            callback(true, prefabHash, true, SpawnLocationManager.GetRandomSpawn(), Quaternion.identity);
        }