🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Trouble with understanding networked IDs

Started by
2 comments, last by xqwzts251 4 years, 9 months ago

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.

 

 

Advertisement

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

enum Bool { True, False, FileNotFound };

Thank you so much!

This topic is closed to new replies.

Advertisement