Giter Site home page Giter Site logo

unity-technologies / com.unity.netcode.gameobjects Goto Github PK

View Code? Open in Web Editor NEW
2.1K 465.0 420.0 57.62 MB

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.

License: MIT License

C# 99.93% Python 0.06% Shell 0.01%
unity unity-3d multiplayer networking csharp mlapi hlapi unity3d netcode owner-multiplayer-sdk

com.unity.netcode.gameobjects's Introduction

Netcode for GameObjects

Forums Discord Manual API

GitHub Release

Welcome!

Welcome to the Netcode for GameObjects repository.

Netcode for GameObjects is a Unity package that provides networking capabilities to GameObject & MonoBehaviour workflows. The framework is interoperable with many low-level transports, including the official Unity Transport Package.

Getting Started

Visit the Multiplayer Docs Site for package & API documentation, as well as information about several samples which leverage the Netcode for GameObjects package.

You can also jump right into our Hello World guide for a taste of how to use the framework for basic networked tasks.

Community and Feedback

For general questions, networking advice or discussions about Netcode for GameObjects, please join our Discord Community or create a post in the Unity Multiplayer Forum.

Compatibility

Netcode for GameObjects targets the following Unity versions:

  • Unity 2021.3(LTS), and 2022.3(LTS)

On the following runtime platforms:

  • Windows, MacOS, and Linux
  • iOS and Android
  • Most closed platforms, such as consoles. Contact us for more information about specific closed platforms.

Development

This repository is broken into multiple components, each one implemented as a Unity Package.

    .
    ├── com.unity.netcode.gameobjects           # The core netcode SDK unity package (source + tests)
    └── testproject                             # A Unity project with various test implementations & scenes which exercise the features in the above packages.

Contributing

We are an open-source project and we encourage and welcome contributions. If you wish to contribute, please be sure to review our contribution guidelines.

Issues and missing features

If you have an issue, bug or feature request, please follow the information in our contribution guidelines to submit an issue.

You can also check out our public roadmap to get an idea for what we might be working on next!

com.unity.netcode.gameobjects's People

Contributors

andrews-unity avatar angusmf avatar ashwinimurt avatar becksebenius-unity avatar bendoyon avatar chrispope avatar darvell avatar fluong6 avatar gabrieltofvesson avatar ian-m-unity avatar jaglitegrann avatar jdcook avatar jeffreyrainy avatar jesseolmer avatar kvassall-unity avatar lukestampfli avatar marcbritton avatar mattwalsh-unity avatar noelstephensunity avatar paulpach avatar pdeschain avatar pkaminski avatar samuelbellomo avatar shadauxcat avatar simon-lemay-unity avatar simon-winter avatar thusspokenomad avatar twotenpvp avatar wackoisgod avatar zain-mecklai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

com.unity.netcode.gameobjects's Issues

Need NetworkingManager.OnServerDisconnect override

The room managment code for my project expects an event when a player disconnects from the game server. The existing HLAPI code used NetworkManager.OnServerDisconnect. Could we get a similar override?

Example Not Working

Hi Albin,

First of all congrats for the nice job you've done here. I'm relatively new in the Unity world. I have followed some tutorials and I have implemented some Unity projects based on my curiosity. After familiarizing myself with some basic HLAPI features in the Multiplayer Networking Unity-tutorial, I came across MLAPI which is inspired from the HLAPI as you mentioned.

Having read your wiki I tried to test your example, but I didn't manage to get it working. So, I what I've done so far is to download your example project, load it on my Unity2017 and from the Build Settings I choose "Build And Run". When the standalone application starts, pressing any of the three buttons (Server, Host, or Client) has no effect. When I try it in the Unity editor I see no difference in selecting any of the three options. My intention was to use the standalone app as the HOST and the Unity Editor as the CLIENT. Could you please give me a hint on what I'm doing wrong? Moreover, could you briefly describe what someone should expect to get from this example?

Thanks in advance for you response.

Test latency

Issue Type

  • Bug
  • Enhancement / Feature
  • Question
  • Other

Description

I'm trying to estimate the total time it takes for a message to be sent from the client to the server, till the time the server acknowledges that he received the message.

Is there a way to calculate rtt similar to the GetRTT?

Targeted Authority System

For targeted messages, currently, any client can send messages targeted at any game object.
You can manually enforce Authority by checking the clientId in the message callback, but an attribute or some way of simplifying authority enforcement should probably be added.

Currently this is the easiest:

private void MyMessageCallback(uint clientId, byte[] data)
{
    if(clientId != ownerClientId)
        return;

//Now we know that the owner of this object is the one who sent the message.
//This even works for Passthrough message as the server sets the clientId source for us, thus it's not fakable by clients.
}

Reduce memory allocations on fixed size messages

Certain messages sent by the MLAPI has a fixed length. (Fixed as in constant size or a size that depends on the NetworkConfig which won't change during runtime).
These messages currently allocate their memory at runtime. These could be preallocated when the MLAPI get's initialized. The allocations are not big, just a few bytes but there is no reason not to pre-allocate them.

Update() vs FixedUpdate()

Issue Type

  • Bug
  • Enhancement / Feature
  • Question
  • Other

Description

In your NetworkedTransform component, shouldn't you use FixedUpdate() instead of Update()? As far as I have understood, when it comes to rigidbody dynamics and changes in an object's transform, we should use FixedUpdate(). I think it has to do with the fact that FixedUpdate() is executed in sync with Unity's physics engine, whereas Update() can vary out of step with the physics engine, either faster or slower. Could you please explain me why you decided to use Update() instead?

Thanks

Is it possible to have multiple listeners on different ports in a single Unity instance?

Hey there,
I was wondering if MLAPI allows multiple listeners withina single Unity instance to listen on different port numbers and then be able to handle messages differently based on which incoming port was used? I will be having a few local Unity instances running on a single server (Master, Login, World, Chat) that will each connect to the Master instance on one port and communicate over that, but then clients will connect to Master on a different port. Is this something that do that? This is so that if I need to add an additional World or Chat server down the line I just need to fire one up on a different server and it will then connect automatically to Master and register itself as a playable game World to send clients to as it is a persistent world RPG.

Thanks,

Need NetworkingManager.IsClientConnected() or alternative

Hi, existing backend management code polls NetworkManager.IsClientConnected to check for connection to the game server in a coroutine while waiting after it receives an access token for the room. Once true, it sends the token to the game server. At that point it waits for IsClientConnected to become false again before loading a "disconnect" screen. Could use an equivelant way to determine if client is connected.

Problem with Spawning at runtime and with NetworkedTransform

Hi,

I try to implement a jenga tower. So, I have introduced a JengaBlock prefab. I have added the Networked Object, the Tracked Object, the Networked Transform, and the Rigidbody component. I have also included this prefab in the Networked Prefabs of my Network Manager. Then I have created an empty object and named it Spawn Networked Objects. With the Spawn Networked Objects selected I added a new script and named it SpawnNetworkedObjects.cs. For convenience I'm attaching you the script so you can reproduce the buggy behavior I get.

using MLAPI;
using MLAPI.Data;
using MLAPI.MonoBehaviours.Core;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnNetworkedObjects : NetworkedBehaviour
{
    public GameObject JengaBlock;
    private GameObject[] JengaBlocks;
    const int height = 8;

    // This is equivalent to overriding OnStartServer()
    private void Start()
    {
        JengaBlocks = new GameObject[height * 3];
        NetworkingManager.singleton.OnServerStarted = makeJengaBlocks;
    }

    void makeJengaBlocks()
    {
        float xDistPercentage = 0.5f;
        float yDistPercentage = 0.4f;
        int i = 0;

        for (int y = 0; y < height; y++)
        {
            for (int x = -1; x <= 1; x++)
            {
                if ((y & 1) == 0)
                {
                    JengaBlocks[i] = Instantiate(JengaBlock, new Vector3(x * xDistPercentage, y * yDistPercentage, 0.0f), Quaternion.identity);
                    JengaBlocks[i].GetComponent<NetworkedObject>().Spawn();
                }
                else
                {
                    JengaBlocks[i] = Instantiate(JengaBlock, new Vector3(0.0f, y * yDistPercentage, x * xDistPercentage), Quaternion.Euler(0.0f, 90.0f, 0.0f));
                    JengaBlocks[i].GetComponent<NetworkedObject>().Spawn();
                }
                i++;
            }
        }
    }
}

There are two problems here:

  1. although the Jenga tower is properly constructed on the Host, this is not the case for the Client.

  2. When I interact with the Jenga blocks in one of the Clients, the blocks seem to not be synchronized between the Client and the Host.

How can I fix these issues? Is it something I'm doing so wrong here?

Thanks!

NetworkStart not called (for scene objects?)

I have a static scene object representing an "MLAPI Room". It has a NetworkBehaviour script and the NetworkedObject script attached in the editor. The NetworkStart override never fires. It seems that it is only called from InvokeBehaviourNetworkSpawn, which only seems to be called for new players or added objects. I can't quite figure out whether "MLAPI_ADD_OBJECT" is ever sent for scene objects, but it doesn't look like it, so I assume that's why this isn't working.

I'll try testing a spawned object to verify I can get NetworkStart called on those. If so, it should be possible to work around by using the recently added NetworkingManager.OnServerStarted.

Spawning A Player and a Non-Player Object

Hi,

I try to implement the following simple game. Two clients (the host and the remote-client) move a Cube object that is on the Server.

I have introduced the NetworkedObject, the NetworkedTransform and the TrackedObject components. onto the Cube's prefab. I have selected the "Server Only" box in its NetworkedObject component. In my Network Manager object I have set the size to 1 in order to have two spawnable Prefabs, the Cube and the Player. When I start the standalone application and I select Host, only the Player appears, not the Cube. Then, I run the application from unity's editor as a Client and the second player appears. The two scenes seem to be well synced but the Cube is missing.

I have two questions:

  1. How do I spawn an object? I want the players to start from different initial position because some weird stuff happen when they collide in the very beginning.

  2. How am I supposed to instantiate the Cube properly and make it appear in the game? In the Multiplayer Networking Unity-tutorial (where the HLAPI was used instead), the non-player objects were instantiated within the overridden function OnStartServer(). What is the equivalent function in MLAPI? If there is not one, where should I instantiate my Cube? Furthermore they were using NetworkServer.spawn(non-player-object). What's the equivalent of this in MLAPI?

Thanks!

Feature: Server-only NetworkedBehaviour

Issue Type

  • Bug
  • Enhancement / Feature
  • Question
  • Other

Description

Equivalent of Unity's "Server only": Tick this checkbox to ensure that Unity only spawns the GameObject on the server, and not on clients.

Feature Request: RigidBody interpolation

Would be nice to have physics interpolation built into NetworkedTransform as well as the existing transform interpolation. I only use 2D at this point, but presumably folks will want 3D as well. :)

Improve NetworkedTransform

Improve the networked transform to work better with Hosts & non player objects. Possibly add Extrapolation at some point?

Observer system initial object

Issue Type

  • Bug
  • Enhancement / Feature
  • Question
  • Other

Description

Currently, every networkedObject is replicated when a client first joins. This is due to how the MLAPI was designed before the observer system. With the addition of it, only observed objects should even be sent from the beginning. Making clients unaware of non-observed objects. This might lead to unexpected behaviour and future limitations. It would not allow host migration etc where clients have to be aware of the objects even if they don't neccecarly have the latest state.

One alternative would be to still tell every client of every object's existance but with limited information. Where things like SyncedVars, position? are excluded and only neccecary information is sent. Many parts of the MLAPI depend on every client knowing about every object. So minor changes are required in a few places. Ex ownership changes ignore observers.

Your Environment

  • Unity Version: {Please write here}
  • MLAPI Version (Commit # or release version): v1.1.1

NetworkingConfiguration class missing

Hi Albin,

I decided to start my own simple example from scratch to better understand MLAPI. For now I'm only having one cube as a prefab with the NetworkedObject component added, a NetworkManager object with the NetworkingManager component added and a HUD object with the NetManagerHub.cs script taken directly from your example in order to manage network configurations. However, I get the following error already:

Assets/NetManagerHud.cs(13,13): error CS0246: The type or namespace name 'NetworkingConfiguration' could not be found. Are you missing 'MLAPI.Data' using directive?

Any hint on what am I missing here?

Thanks.

Unity package path & dlls

I know there is no common practice for this but, that would be nice if like some other packages, MLAPI would target a Plugins/MLAPI path when installing.

Support for netcode.io?

Issue Type

  • Bug
  • Enhancement / Feature
  • Question
  • Other

Description

netcode.io is a protocol for using UDP from the browser, as in HTML5 and WebGL. It is currently only supported in Firefox and Chrome, and only by installing an extension. If this can be fit to the transport interface in MLAPI, it would provide a superior solution vs Websockets.

Links:
https://gafferongames.com/post/why_cant_i_send_udp_packets_from_a_browser/
https://github.com/networkprotocol/netcode.io
https://github.com/RedpointGames/netcode.io-browser

Since support for this protocol is extremely opt-in, this would probably not be useful to a ton of people. Consider this feature request to be a wild hope for the future...

SyncedVar hooks

One of the handy things in HLAPI syncvars is that you can define a hook for them to invoke. Can we get the same?

Warp in NetworkedNavMeshAgent

Not sure you want Warp for correction on a low frequency...probably should treat that as a drift correction while it's navigating, and if it's stationary within a short distance, leave it alone, like arrival distance where it considers itself having arrived when it's close to the destination.

NetworkedObject reports invalid NetworkedPrefabName during Build

During build, the OnValidate method runs on NetworkedObjects, not even necessarily on objects in a scene. The reason is unknown.

In addition, the OnValidate method finds out that the NetworkedPrefabName is empty. Thus throwing a warning and correcting it. Even though all instances and prefabs of the reporting object has been checked to not have a empty PrefabName.

My suspicion is that this has to do with how the Unity editor works during builds.

I am unsure if it causes any issues or if it only means that we get a warning message in the console.

Add NetworkBehaviour Targeted Messages

Currently, "Target" messages get's invoked on every listening behaviour of a given object. A target system that targets a specific behaviour similar to how SyncedVars work should be added and should replace the current Target system.

Syncvar supported type extensions

It would be nice to be able to sync arbitrary types. I would like to be able to send, for instance, two strings so that the handler (maybe a hook from #21) gets both values at once. Would it be possible to call a user defined de/serializer to enable something like that?

Feature Request: Add/Remove player to NetworkedObject

My project doesn't spawn player objects as controllable objects because the player is supposed to be able to switch their control to any networked object that has player controls available. This means I need the ability to turn on player position synchronization for any object, as well as remove it. In the HLAPI this translates to:

  • registering all prefabs I will use (by registering the SpawnHandler and UnSpawnHandler hooks,) spawning some objects
  • spawning one permanent player object that serves as a persistent object for communicating with the server, such as to request a new netobject be spawned, or to request control of an existing netobject.
  • once the server has been asked to spawn a player or grant control to a player, it can do appropriate checks, then add/replace that object in player control

I believe the only thing currently missing from MLAPI for this are signatures like:

NetworkedObject.AddControl(NetworkConnectionObject conn, bool replace)

NetworkedObject.RemoveControl(NetworkConnectionObject conn)

Spawn() method doesn't set ownership of spawned object to the Server

Issue Type

  • Bug
  • Enhancement / Feature
  • Question
  • Other

Description

When I spawn an object with your Spawn() method from my Network Manager, shouldn't the default ownership go to the server? Cause when I spawn an object from my network manager the object is not owned by anyone. Both on the Server's and on the Client's side the isOwner of the spawned object is false. So, who owns the object?

This is how I do it on my Network Manager

public GameObject cubePrefab;

private void Start()
{
  NetworkingManager.singleton.OnServerStarted = SpawnCube;
}

void SpawnCube()
{
  cube = Instantiate(cubePrefab, new Vector3(-2.0f, 0.5f, 2.0f), Quaternion.Euler(0, 0, 0));
  cube.GetComponent<Renderer>().enabled = true;
  cube.GetComponent<NetworkedObject>().Spawn();
}

Thanks

NetworkAnimator and Proximity

Shouldn't NetworkAnimator have Proximity control? Maybe we don't want to notify every client in the game world about lights going on in a house someplace when it happens but any client that comes near later should then get the updated states?

Player is not Spawned in Multiplayer Game

Description

So far, I have been mainly working with your v1.1.1 release. It was today that I downloaded your master and I had some issues with my multiplayer game. I have 3 machines. My desktop (Windows 10) hosts the Server. The two laptops (Windows 7) operate as Clients. With v1.1.1 everything was performing smoothly. This is not the case any more with the master I downloaded today.

  1. I start the Server on my Desktop. The Server only has a scene with one Networked Object, a cube in this case.

  2. Client-A joins the game. I can see the player-bot of Client-A and the cube both on the Server and on the Client-A scene. And they are perfectly synced.

  3. Client-B joins the game. The player-bot of Client-B appears on the Server and on Client-B scene but not on Client-A scene. Client-A can see the cube which is moved by the player-bot of Client-B, but not the player-bot itself. It's like a ghost is moving the cube. So, the player-bot of Client-B is not spawned in the scene of Client-A.

You must have introduced a bug in one of your latest releases, but since I have not been following them, I can't say where the problem is. I can start by downloading v1.2.0 and see if there is any problem there. So, I will first search per release and once I detect the problematic one I will go for the latest commits before that release.

Your Environment

  • Unity Version: Unity Version: 2017.4.0f1
  • MLAPI Version: v1.1.1

Performance question

Hey there again,
I had a question in regards to performance. I came across this benchmark a while back and saw the grotesque memory usage that UNet required once you started to get to the 500-1000 connection range. Is this something that MLAPI would end up still being susceptible to, or would it not be a worry?

Thanks,

SyncedVar not syncing on client when object is spawned after client has joined.

Issue Type

Bug / Question

Description

SyncedVars dont get synced on initial spawn when spawning a gameobject through the NetworkedObject Spawn methods.
Is that how it should work?

My guess is that something gets wrong with the NetworkedObjects observers.

I have a player prefab for the players that persists and hold important data witch i call "PlayerInfo", I then spawn a character gameobject with ownership witch is the actual object the player is controling on the screen.

Also is there any discord or similar chat available to discuss MLAPI in?

Code

 GameObject characterGameObject = Instantiate(m_characterPrefab, position, Quaternion.identity);
            characterGameObject.GetComponent<SomeNetworkedBehaviour>().m_someSyncedVar = "HelloWorld";
            characterGameObject.GetComponent<NetworkedObject>().SpawnWithOwnership(networkedObject.OwnerClientId);

Expected Behavior

I would expect that SyncedVars set by the server before calling the spawnmethod would be fully synced to the clients when the clients spawns the object.

Actual Behavior

SyncedVars are not synced on inital sync and i am also unsure if they are syncing at all.

SyncedVars on objects that is already spawn when joining as a client is syncing and initiated as they should.

Your Environment

  • Unity Version: 2017.3.1f1
  • MLAPI Version (Commit # or release version): v1.3.0

Need NetworkedBehaviour.OnStartServer

The existing HLAPI room management scripting in my backend code uses an override on NetworkBehaviour called OnStartServer to trigger its own initialization. Could we get a similar override added to NetworkedBehaviour?

BitWriter Boxing

Issue Type

  • Enhancement / Feature

Description

Currently the BitWriter boxes everything you write to objects. A holder struct should be used in place.

Your Environment

  • MLAPI Version (Commit # or release version): v1.1.1

NetworkedNavMeshAgent won't move

Issue Type

  • Bug

Description

NavMeshAgent's Warp resets the destination so the client will not walk.

  1. Server sets agent's destination -> Client starts to move.
  2. Server warps the agent -> Client stops moving
  3. Server's agent reaches destination while client stays idle

In my tests I've just completely removed the warping and the client's agent moves to its destination as expected. I think warping should only be done when
a) a certain offset (~ agent-speed * 2) between server and client agents exist
and
b) before destination is set, so it requires some sort of sequence

Your Environment

  • Unity Version: 2018.01.f02
  • MLAPI Version 35a8ff1

Deployment on HoloLens fails

Description

When I try to deploy my MLAPI example on my HoloLens device I get the following errors:

2> Copying unprocessed assemblies...
2> Running AssemblyConverter...
2> Failed to fix references for method System.Byte[] MLAPI.NetworkingManagerComponents.Cryptography.CryptographyHelper::Decrypt(System.Byte[],System.Byte[])
2> Failed to fix references for type MLAPI.NetworkingManagerComponents.Cryptography.CryptographyHelper
2> System.Exception: Failed to resolve System.Security.Cryptography.RijndaelManaged
2> at Unity.ModuleContext.Retarget(TypeReference type, GenericContext context)
2> at Unity.FixReferencesStep.Visit(MethodDefinition method, GenericContext context)
2> at Unity.FixReferencesStep.Visit(TypeDefinition type)
2> at Unity.TypeDefinitionDispatcher.DispatchType(TypeDefinition type)
2> at Unity.TypeDefinitionDispatcher..ctor(ModuleDefinition module, ITypeDefinitionVisitor visitor)
2> at Unity.FixReferencesStep.ProcessModule()
2> at Unity.ModuleStep.Execute()
2> at Unity.FixReferencesStep.Execute()
2> at Unity.Step.Execute(OperationContext operationContext, IStepContext previousStepContext)
2> at Unity.Operation.Execute()
2> at Unity.Program.Main(String[] args)

Do you have any ideas what's causing this failure and how can I fix it?

Thanks

Your Environment

  • Unity Version: 2017.4.0f1
  • MLAPI Version: v1.1.1

Feature: SyncListStruct<T>

Issue Type

  • Bug
  • Enhancement / Feature
  • Question
  • Other

Description

HLAPI's SyncListStruct can be used to synchronize lists of structs from server to clients. This would be a great addition for MLAPI.

Does it work to run MLAPI in two different projects?

Hi, I had been trying to use HLAPI to implement object sharing between a server and client which are in two different projects. Got to know that this is not possible in HLAPI. I was successful in using LLAPI to implement message exchanges between the server and the client in the two different projects. Was wondering if MLAPI would be possible to be run on two different projects for doing the object sharing? Thanks!!

Syncing object transforms

Hi,

I was following the instructions on the wiki and also downloaded your example. I setup a scene with a network manager (added the MLAPI component Networking Manager to it), then a cube prefab (added the MLAPI component Networked Object) and then added an HUD object with your NetManagerHud.cs script from your example to do the network configurations.

For some reason, I am getting the error when starting the server:

KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[System.String,System.UInt32].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
MLAPI.NetworkingManagerComponents.NetworkSceneManager.SetCurrentSceneIndex ()
MLAPI.NetworkingManager.Init (MLAPI.NetworkingConfiguration netConfig)
MLAPI.NetworkingManager.StartServer (MLAPI.NetworkingConfiguration netConfig)
NetManagerHud.OnGUI () (at Assets/NetManagerHud.cs:33)

which is the line NetworkingManager.singleton.StartServer(config);

This also happens in the StartClient and StartHost if I press those buttons instead.

Any idea what could be wrong? Tried googling but couldnt really find any help that could be applied here.

I am running Uity 5.6.3p2 (64bit).

Thanks!

Feature Request: Support multiple listeners per host

First!

Awesome project! Looking forward to integrating, as you know. So, on to the feature...

API to support referencing connections by both their connection id AND listener/host id so that multiple hosts can be started for a single server instance. My suggestion is to change signatures to:

  • take the connection object instead of connectionId
  • take both connectionId and hostId

Thanks! More to come.

Destroying owned objects when client disconnect bug

Issue Type

Bug, Question

Description

When a client disconnects from the server the server will remove those GameObjects owned by that client. But Unity's destroy method waits until the end of that frame before actually removing the object, which means that NetworkObjects OnDestroy method is not invoked directly.
The NetworkObject is calling the the SpawnManagers OnDestroyObject method which in the case of owning the object is dependent on that the client is still in the NetworkingManager.singleton.connectedClients. but it is removed from there right after the call to Unity's destroy method, and because it is delayed it is removed before it needs to be used in the SpawnManager.

A solution would be to call Unity DestroyImmediate method. But it is discouraged to use in none editor code.

Also, why is not PlayerObjetcs GameObject destroyed? it only destroys the NetworkingObject of the PlayerObject. Is there are reason for this?

Code

//Code from within NetworkingManager - OnClientDisconnectFromServer
if(NetworkConfig.HandleObjectSpawning)
                {
                    if (connectedClients[clientId].PlayerObject != null)
                        Destroy(connectedClients[clientId].PlayerObject);
                    for (int i = 0; i < connectedClients[clientId].OwnedObjects.Count; i++)
                    {
                        if (connectedClients[clientId].OwnedObjects[i] != null)
                            Destroy(connectedClients[clientId].OwnedObjects[i].gameObject);
                    }
                }
                connectedClientsList.RemoveAll(x => x.ClientId == clientId);
                connectedClients.Remove(clientId);

Your Environment

  • Unity Version: 2017.3.1f1
  • MLAPI Version (Commit # or release version): 34c511c

v1.3.0 MLAPIEditor.cs script from MLAPI_Installer does not compile due to missing dependencies

Issue Type

Bug

Description

The Getting Started wiki page says the easiest way to get started is to download the MLAPI_Installer.unitypackage from the releases page. I downloaded the latest version which is v1.3.0.

When I import the package a compile error is displayed:
"Assets/Editor/MLAPI/MLAPIEditor.cs(9,13): error CS0246: The type or namespace name `GithubRelease' could not be found. Are you missing an assembly reference?"

The offending line is:

    private GithubRelease[] releases = new GithubRelease[0];

GithubRelease is undefined at this point.

I then downloaded the previous release v1.2.2, which contains additional JSON/GithubAsset.cs and JSON/GithubRelease.cs files which aren't in the v1.3.0 version. The installer then compiles and works fine.

Expected Behavior

MLAPI_Installer.unitypackage should be self contained and not depend on files in previous versions.

Actual Behavior

Must use files from previous release.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.