How to Properly Manage Arrays in ECS Components in 8thWall?

Hi everyone,

I’m currently working with the ECS (Entity Component System) in 8thWall, and I’m facing some difficulties in managing arrays within a component’s data.

What I’m Trying to Achieve:

I want to create and manage an array of entity IDs (collisionObstacleEntities) within a component, where each entity has its own independent array. This array is meant to store IDs of entities that are created dynamically and associated with the parent entity.

My Question:

How can I properly manage and store an array within an ECS component in 8thWall, ensuring that each entity has its own independent array? Is there a specific method or best practice to follow for this kind of data management in 8thWall’s ECS system?

Thanks in advance!

Excellent suggestion!

Currently you can’t have dynamic lists or arrays as a schema or data type. You can work around it by creating an array at the top of the component file outside of the component definition. Alternatively you can store arrays in the window which is accessible from anywhere, but it’s definitely not a best practice.

You could also decompose your object into what data you want it to hold. For example:

{ name: “John”, age: 32, favoriteFood: “Steak” }

Would become:

personName: ecs.string,
personAge: ecs.i32,
personFavoriteFood: ecs.string

1 Like

Thanks for your suggestion :hugs:. However in a scene containing 100 entities creating data without an array that can be initialized in the schema is very difficult in managing gameObject objects in the game :grimacing:. I am looking forward to finding a better solution for this problem.