From 7aa56551d99d91647485392df5ad643bf7dc063b Mon Sep 17 00:00:00 2001 From: Garrett Swann Date: Fri, 29 Dec 2023 12:44:22 -0800 Subject: [PATCH] Fix relationship example by specifying inout. --- examples/cpp/relationships/union/src/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/cpp/relationships/union/src/main.cpp b/examples/cpp/relationships/union/src/main.cpp index 2007d7dca3..791b731350 100644 --- a/examples/cpp/relationships/union/src/main.cpp +++ b/examples/cpp/relationships/union/src/main.cpp @@ -35,10 +35,12 @@ int main(int argc, char *argv[]) { ecs.component().add(flecs::Union); // Create a query that subscribes for all entities that have a Direction - // and that are walking + // and that are walking. + // with() requests no data by default, so we must specify what we want. + // in() requests Read-Only flecs::query<> q = ecs.query_builder() - .with(Walking) - .with(flecs::Wildcard) + .with(Walking).in() + .with(flecs::Wildcard).in() .build(); // Create a few entities with various state combinations @@ -61,8 +63,8 @@ int main(int argc, char *argv[]) { q.iter([&](const flecs::iter& it) { // Get the column with direction states. This is stored as an array // with identifiers to the individual states - auto movement = it.field(1); - auto direction = it.field(2); + auto movement = it.field(1); + auto direction = it.field(2); for (auto i : it) { // Movement will always be Walking, Direction can be any state