Skip to content

grab entity pair components un system term ? #1149

Answered by copygirl
sigzegv asked this question in Q&A
Discussion options

You must be logged in to vote

How to deal with relationship pairs is explained in the Queries section, specifically Pairs.

If you want to match a specific pair:

.query.filter.terms = {
    { ecs_id(position_t) },
    { ecs_pair(ecs_id(controller_t), ecs_id(ai_t)) },
},

If you want to match every controller:

.query.filter.terms = {
    { ecs_id(position_t) },
    { ecs_pair(ecs_id(controller_t), EcsWildcard)) },
},

This will match the same entity multiple times for each wildcard matched.
And you can get the matched target like this from the iterator:

ecs_id_t ctrl_pair = ecs_field_id(&it, 2); // index = 1 is position, 2 would be the controller pair
ecs_entity_t second = ecs_pair_second(world, ctrl_pair);

Hope this helps.

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by sigzegv
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@copygirl
Comment options

@sigzegv
Comment options

@copygirl
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