sschmid / Entitas

Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
MIT License
7.09k stars 1.11k forks source link

Question about integrate in online game. #839

Open juliolitwin opened 5 years ago

juliolitwin commented 5 years ago

Hi,

I have question.:

So, I already have some project, is like "Bomberman" but is online - (login/channel/lobby/room/ingame) and server is not integrated with the client (unity), as the game is very simple, it may not be necessary to use the Entitas, but I would like to learn to use ECS even if the project is basic.

My question is:

Thanks, Cheers.

zhuchun commented 5 years ago

In the client side question, will it be necessary to rewrite many things?

No, You can use BehaviorComponent/ OOP scritps as services, check this out How I build games with Entitas (FNGGames)

Would I have to rewrite it on the server side as well?

Assuming that you're building a 100% server authoritative game. The answer heavily depends on what's your server side. If you want to use the headless server, then no, it's just Unity without graphics. However, if you're going to build things from a pure C# project, then yes, you can't use any Unity things, at least for the core layer.

juliolitwin commented 5 years ago

In the client side question, will it be necessary to rewrite many things?

No, You can use BehaviorComponent/ OOP scritps as services, check this out How I build games with Entitas (FNGGames)

Would I have to rewrite it on the server side as well?

Assuming that you're building a 100% server authoritative game. The answer heavily depends on what's your server side. If you want to use the headless server, then no, it's just Unity without graphics. However, if you're going to build things from a pure C# project, then yes, you can't use any Unity things, at least for the core layer.

Yo,

Thanks alot for reply me! Then, about server side, I have already developed, it's pure C# project, but I mean, I don't want to add Entitas on my project, only want to know if I need to change something in server side, because with Entitas, it's using ECS logic.

So, this means that using Entitas only on the client side, will not interfere in server logic? What I'm worried about is how I will interact with the components of the Client <-> Server (for example: update Player's position on the server for all clients), or I don't need to care about this?

Cheers.

zhuchun commented 5 years ago

Maybe it's NOT a good idea unless your server-side application is just a relay server(like a broadcaster).

In practice, I always try to keep both side scripts as similar as possible, leave alone that the difference between ECS and Component system is huge. It would be painful to implement everything in 2 different ways. Assuming you are building a fast-paced network game, server and client usually share the same code but just work in a different way. Say a client send command input to the server and then the server sends command result and world state back. In order to get a nice and smooth client-side prediction result, your code should be deterministic. Implement deterministic code for both ECS and Component system would be a nightmare, at least to someone like me.

In short, you can write both sides in either way, no problem.

Regarding how Entitas works, it knows nothing about Unity, just like your server side code. So you can reference the UnityEngine namespace in a system and ask it to update transform position for you.

juliolitwin commented 5 years ago

I do not see necessity to use Unity as a server, as I said, it's a "Bomberman Online 3D", but even then, I still use a 2D grid to do verifications (player movements, AI and etc), it also includes the other logics (shop, items, chat, social and etc) and any physics needed, it will be easy to simulate on the server itself. My server is also separated into different parts, such as LoginServer, RoomServer, LobbyServer, and DBServer.

It would not be appropriate to use Unity as a server for all these servers (in which I still want to upgrade and add a new server to manage the servers), it would only be "appropriate" to use Unity as the only server for the RoomServer, then I of the work to have to develop the entire structure of the other server outside of Unity and then I would end up having all the work to have to develop the entire structure of the other server outside of Unity to the other servers.

Cheers.

zhuchun commented 5 years ago

Oh, I see. That's normal. Regarding your first two questions, you may need to rewrite your game logic on the RoomServer/GameServer. Otherwise, your teammate may yell "Oh WTH, why this game logic is ECS on the client but OOP on the Server?" 😄 So it's better to keep them as is.

Entitas itself is easy to learn and use, the code generator is the only black magic there.

juliolitwin commented 5 years ago

It's just a personal project, so I don't have to worry about teammate. :P

I will have to rethink in other alternatives in this case, because I would not like to have to rewrite to much the server, because in addition to learning a new technology, such as ECS with Entitas, I would like to add support for multiple rendering and processing objects for the client, without having to worry about a drastic fall of ping (example: adding 200+ AI's in a single scene in a short distance, another example would be a type of battle royale).