10

A pure Entity - Component - System architecture means that: Every object in your game is an Entity. However, an entity itself has neither any data nor any code. It is an abstract concept not represented by any data structure. It is just an ID number. There is no "class Entity". All the data about the entities in your game is in Components. A ...


8

It is perfectly possible to mix both styles. The same GameObject can have some of its functionality implemented with the new ECS system and other functionality in classic MonoBehaviour events. What Unity recommends in their ECS tutorial is in fact to start with a project which uses the old style and then look for features which you think would benefit from ...


8

As a pattern ECS and data oriented programming in general are closer to pure C than C++. Entity component systems consist of three major elements. Components are simply holding data; they shouldn't hold any logic. A simple struct should be enough to model them in C. Systems is where all your logic lives. Finally, Entities don't hold anything (logic or ...


6

Games typically approach this type of issue using a transformation hierarchy. In this model, each entity can be treated as a "child" of a "parent" entity. The entity's local position and orientation components are interpreted to be relative to the position and orientation of the parent. Parent entities may in turn have their own parents, grandparents, etc.,...


5

I was considering voting to close this question as opinion-based, but I think there are a couple of misunderstandings about Entity-Component Systems and Data-Oriented Design here that are worth addressing. ECS is just a tool Like any programming pattern or principle, it exists to help you write good software. It is not an unbreakable law of physics or a ...


5

One nice thing about systems in an ECS architecture is that they don't all necessarily need to follow the same structure of for(int i = 0; i < entities.length; i++) process(entities[i]); and then implement process(entity) as if there would be no other entities in the universe. If there is a smarter way to process entities than sequentially in natural ...


4

Update I have wrote Theraot.ECS inspired by Fastest way to look up an entity with a set of components?. However this answer motivated me to allow to specify custom containers for particular types. It would be necesary to provide an adapter to the interface IIntKeyCollection<TValue> exposed in the project. Which would in theory allow the ECS to use a ...


4

Just like with any software architecture question, the short answer is "It depends..." Where do I put that quadtree? Any auxiliary data structures needed by one system only should be part of that system. So if that quadtree is only used by the CollisionSystem, then you can make it part of the system. But if that quadtree is used by many different ...


4

The way ECS implementations like the new one in Unity work is to use the concept of Archetypes. An Archetype is the description of the components in a particular entity. Given sets of components, like {position,rotation,mesh} and {position,rotation,particles}, you have two different Archetypes. Both of them contain {position,rotation}, but the first ...


4

I think you're pretty close. Here is one option, which I'd try to implement first. You need 2 components Input Camera I assume you'd create an entity and add them like this: ECS::Entity * UserCameraManager = EntityWorld->create(); UserCameraManager->assign<Input>(); UserCameraManager->assign<Camera>(getMainUserCamera()); Each frame, ...


4

Here's an article explaining it quite clearly: https://www.gamedev.net/articles/programming/general-and-gameplay-programming/understanding-component-entity-systems-r3013/. A component can be likened to a C struct. It has no methods and is only capable of storing data, not acting upon it. An entity is something that exists in your game world. Again, an ...


3

Make a Immovable component that contains a set※1. The idea is that when this set is empty the entity can move. We can do this by having The MovementSystem check, however that would imply iterating over entities that are set to not move. Ideally the MovementSystem would not have to do that※2. So, for example, your Immovable component has a set of strings, ...


3

feels like I'm violating the ECS rule There is no ECS police that will come and put you in ECS Jail. This is your architecture, you set it up how it fits your needs. having any functionality in components. I don't see any functionality in what you suggest. I only see data. At their core, all of those are effectively shapes and will have to be treated ...


2

I'd recommend solving this in pretty much the usual way: with a scripting language. (This could be a text-based language like LUA, a nodegraph based visual scripting tool, pre-digested bytecode, etc.) ECS exists to help make the things you do hundreds, thousands, or even more times each frame execute as efficiently as possible. But one-off level scripts ...


2

There are a couple of ways, and they will depend on the implementation of the rest of your system. Here are a few of those I've seen. You could manually tell the system(s) that a new component of a specific type has been added or removed to an entity. The system then goes visit the entity, and checks if there are other components that would make this ...


2

Update I have wrote Theraot.ECS inspired by this answer. It allows you to use Guid, int or whatever for the entities. It will allow you specify how sets of component kinds are handled. Two implementation provided: one uses a binary flag array, the other is based on hash sets. Some lessons learned: QueryCheck (see original answer) should return one of ...


2

Apparently, this is not something that Unity supports at this time. However, there's a workaround by one of the Unity users in the forum. Turning this: into this: 1) Go to: Library\PackageCache\com.unity.entities@0.0.12-preview.32\Unity.Entities\ 2) Create new file: csc.rsp 3) Paste this: -doc:Library\ScriptAssemblies\Unity.Entities.xml -nowarn:1570 -...


2

As a general disclaimer and as DMGregory already stated it: The rules of ECS are not written in stone. Doing it on way has benefits, doing it another way has some others. So, you need to know, what either approach does for you. So, as i don't know your code, i can only theorize what doing it one way would do compared to another. As you should remember, ...


2

Its look like that you have not installed the "Hybrid Renderer" Package. When you want to convert Game objects to Entities then you have to also install "Hybrid Renderer" from package manager. Open up package manager from Windows -> Package manager. Enable "Show Preview Packages" from Advance tab. Then search "hy" then Install "Hybrid Renderer". Same ...


2

Entity movement can be influenced by a variety of sources such as local player, network, or even AI so this is why I often find it easier to treat it as state that is mutated across multiple systems. Lets take this component structure: struct Movement { // -1/+1 implies move either direction along given axis, 0 implies no movement short x, y, z; } If ...


2

My solution to this would be to create a component AITarget which marks an entity as something zombies are supposed to attack (like a player or a civilian). Now the ZombieAI system would receive not one but two separate sets of component-tuples. One for all entities with the Transform and AIPathfinding components and another set with the Transform and ...


2

A common solution to free systems from having to process every single event is by using a subscription architecture. Individual systems can subscribe to specific types of events. The event dispatcher manages these subscriptions and dispatches events to only those systems which subscribed to them. You can then further enhance the architecture by allowing ...


2

To do this in Unreal C++, inside the CPP file you need to do the following: Make sure to include the header component: #include "Camera/CameraComponent.h" Then in the class constructor: CameraComponent = CreateDefaultSubobject <UCameraComponent>("CameraComponent"); From here you need to set up the attachment which is usually to the ...


2

Pipelines The simplest implementation of ECS will run systems sequentially one after the other. Perhaps you are familiar with the idea of fixing your timestep. Simply running systems sequentially in a predefined order blows past that concept. The solution is to have pipelines. Then you can have a pipeline for physics, one pipeline for rendering, and another ...


1

There is capsule collider attached to the bullet in the tutorial, But Mike Geig did not explain any thing about physics and collider, But as much i know unity "MonoBehavior" physics is not working with DOTS Entities. So you have to install either "Havok Physics" or "Unity Physics". More about Physics you can watch tutorials: Leveraging DOTS-powered ...


1

When you have pure tile-based yes-or-no walkability, then there are a lot of optimizations you can do because: Tiles never move Tiles always have the same size Tiles are always found at coordinates which are multiples of the tile size Your collision system doesn't need to check every tile for collisions with entities, because tiles won't move and won't ...


1

I presume since you want a system similar to Entt you're writing in C++. Environment Rendering One of the simplest solutions you may find for the rendering system would be a simple boolean property on the environment class something like IsSelected or IsActive to represent which one is selected for render. The relevant class handling your environments would ...


1

First of all, i don't know how the entt-Framework works. I recognize most of its functions, but some i dont really understand what they do. I try to explain what i did the first time around and also try explain, what problems i had. Maybe that helps what my way of thinking was. Second, i just make some easy assumptions, that can be changed by your liking, ...


1

If the visual position is needed by one set of systems and the logical position by another set of systems, then it might be a good idea to have a separate component for each. Have the Animation system and the Rendering system read the VisualPosition components. Have the game-mechanical systems read the LogicalPosition components. Have the Movement System ...


Only top voted, non community-wiki answers of a minimum length are eligible