Function ecs_entity_init


#include <include/flecs.h>

FLECS_API ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)


Create a new entity. This operation creates a new entity with a single component in its type. This operation accepts variables created with ECS_COMPONENT, ECS_TYPE and ECS_TAG. This operation recycles ids.


world - The world.

component - The component.

The new entity. Find or create an entity. This operation creates a new entity, or modifies an existing one. When a name is set in the ecs_entity_desc_t::name field and ecs_entity_desc_t::entity is not set, the operation will first attempt to find an existing entity by that name. If no entity with that name can be found, it will be created.
If both a name and entity handle are provided, the operation will check if the entity name matches with the provided name. If the names do not match, the function will fail and return 0.

If an id to a non-existing entity is provided, that entity id become alive.

See the documentation of ecs_entity_desc_t for more details.


world - The world.

desc - Entity init parameters.

A handle to the new or existing entity, or 0 if failed.

Mentioned in


Line 1451 in include/flecs.h.