Skip to content

What is the recommended way to create new entities from a system ? #1515

Closed Answered by Greu
Greu asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for you answer.

I tried to switch the system to immediate and it didn't work.
I tried with ecs_defer_suspend/resume and it didn't work.

After checking the component id in my system i realized the problem was somewhere else. It was coming from the way I defined the Position component. I declared it with ECS_COMPONENT_DECLARE(Position) before my system function. Then I defined it later in my main function using ECS_COMPONENT(world, Position);

Replacing ECS_COMPONENT(world, Position); by ECS_COMPONENT_DEFINE(world, Position); fixed the issue.

Here was my test

#include <stdio.h>
#include "flecs.h"

typedef struct
{
    double x, y;
} Position;

ECS_COMPONENT_DECLARE(Position);

static e…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Greu
Comment options

Answer selected by SanderMertens
@SanderMertens
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants