Question about ECS and multiple objects

Right now I am studying ECS and starting to wrap my head around it. I’ve decided to research the subject further because of the benefits it offers. This post is part of that research

One question that poses a small problem in my head is, Suppose I have a player entity with a transform and speed components, and I also have a bullet entity with a transform and speed component, certainly those two different entities will have different behaviour at some point, so how do I differentiate and tell the system I only want the “player” entities transform and speed components when I’m, freerunning just as an arbitrary example, and I only want the “Bullet” entities speed and transform components when I’m shooting someones face off.

Hopefully that’s understandable and sorry if it’s a total noob question, it’s because I’m a noob with ECS lol

An ECS will usually differentiate between “types” based on the components the entity contains. I believe these are usually stored in entity tables (an array of sorts) that you can lookup for specific configurations of components.

Im only learning about ECS and doing my own research the same as you are, so I’m no expert by any means. I found a lot of useful info at:

I’d recommend looking at some of the example projects for ECS frameworks, also in the link above, if you will be looking at building your own.

1 Like

Hopefully your player and bullet will contain more components than just transform and speed. It might be something like health and damage, for instance. So you may ask for all (tranform, speed) get all them or for (tranform, speed, health) and get only moving living entities.

1 Like

Oh ok, see I was confused because on the Unity ECS tutorial the speaker says “Systems will find all entities wth a _____ component and a ______ component… if the entity has a transform and a rigidbody, we know it will be moving” (paraphrasing) which suggested to me that maybe you’d have to specify in the logic which entity with those components will then be utilized which more or less defeats the purpose of ecs really