Jump to content
  • Advertisement

Trouble with understanding networked IDs

Recommended Posts

Hi all!

I want to ask my question on this forum - maybe it's dumb, but I have trouble with understanding crucial part of game networking :/ .


So to illustrate:

1. I have game client in Unity, where I have scene with some objects that I want to network

2. I have written in game server in C#, but not in Unity, which is mostly responsible for handling messages etc.

3. I don't use UNET, I use ENet with wrapper around it and additional functions


My question is: how to assign proper IDs to networked object which will be the same across all clients?

What I've done now is :

1. All of clients have the same Unity scene wit the same objects to network

2. In Unity client-side, each client at Start() pick all components which I want to network

3. Sort all components which compares game objects names and their parents

4. Network ID is just index in an array

And it works across all the clients, so I can send events with id only.


However I don't understand how it's done in other games with above model, or in commercial games.

What I've researched are:

1. Server spawns objects and sends message to the client "Create object of type with params .... and assign network id X"

2. Host client assigns network IDs and sends Unity scene to other clients where they load it - can they do that?

3. Server spawns all of objects

3. Other?


I searched around MLAPI, Mirror and other libraries and I couldn't find how it's generated.

Most of resources mention about assigning ID by server, but it doesn't fit to my model, or I don't understand how it works really.



Share this post

Link to post
Share on other sites

It's not uncommon  for the network ID of "fixed" objects in levels to have their network ID pre-baked into the level data.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!