Skip to content
Bit Quirky Behavior Trees and
State Machines

Search documentation

All topics and APIs

Close returns focus to Search.

What are you looking for?

Try a common topic or enter a complete API identifier.

Browse the reference instead

Esc closes · Tab reaches results · Enter opens the focused link

v0.11.0
Menu

Indexed property

Bind a C# indexer such as this[int] straight from the picker, point its index at a constant or a Blackboard variable, and read, write, or test exactly one entry without writing a wrapper.

A C# indexer is a property with a key. Pick it in the member picker like any other property, give its index a value, and the graph reads, writes, or tests the one entry that index names. The other entries never hear about it.

Dungeon Heist’s PatrolRoute holds four waypoints, each with its own idle pause. The designer wants one of those pauses tuned from the graph, and wants to choose which one without touching the other three. Without an indexer binding that means a wrapper method per entry, or a SetPause(int, float) helper written just to make the graph happy, and a Blackboard full of copies that drift from the route.

PatrolRoute already exposes float this[int index] over the same data GetIdlePauseSeconds reads. Guard2.bqbehavior binds that indexer once: the index comes from the linked_waypoint_index variable, the value from linked_waypoint_pause_seconds, and the write lands on exactly one waypoint.

  • One entry of an ordered set is the graph’s business: a waypoint pause, a lane speed, an inventory slot. Dungeon Heist’s Guard_2 selects a waypoint by number and changes that waypoint’s pause.
  • A member condition should ask about one entry: this[linked_waypoint_index] ≥ 6 tests the selected waypoint and no other.
  • Your component already offers an indexer, and you would rather not add a method whose only job is to forward an index.
Guard_2 reaches waypoint 2 and stands there for the twelve seconds written through the indexer, then walks on to waypoint 3 and keeps its authored four-second pause there, at three times game speed.
Guard_2 reaches waypoint 2 and stands there for the twelve seconds written through the indexer, then walks on to waypoint 3 and keeps its authored four-second pause there, at three times game speed.

linked_waypoint_index reads 2, so typing 12 into the surfaced linked_waypoint_pause_seconds card in Live writes waypoint 2’s pause. Guard_2 reaches waypoint 2 and stands there for twelve seconds, then walks on to waypoint 3 and waits its ordinary four. Played at three times game speed so both pauses fit in one loop.

One index argument addresses one PatrolRoute entryThe PatrolRoute component on Guard_2 exposes float this[int index] over four waypoints, WP0, WP1, WP2, and WP3, each holding an idle pause in seconds. One binding on this[index] takes its index argument from the Blackboard variable linked_waypoint_index, which reads 2, and writes the Blackboard value linked_waypoint_pause_seconds, which reads 12, into the addressed entry. The arrow from the binding points at WP2. WP2 now holds 12 seconds, and WP0, WP1, and WP3 still hold 4 seconds each.PatrolRouteon Guard_2this[index]float this[int index]index02linked_waypoint_indexvalue012linked_waypoint_pause_seconds4 s4 s4 s12 s4 seach waypoint’s idle pauseindex 0 · WP0 is the addressed entrythe index moved to 2, nothing was writtenwrite · WP2 ← 12 · the other three stay at 4One index argument addresses one PatrolRoute entryThe PatrolRoute component on Guard_2 exposes float this[int index] over four waypoints, WP0, WP1, WP2, and WP3, each holding an idle pause in seconds. One binding on this[index] takes its index argument from the Blackboard variable linked_waypoint_index, which reads 2, and writes the Blackboard value linked_waypoint_pause_seconds, which reads 12, into the addressed entry. The arrow from the binding points at WP2. WP2 now holds 12 seconds, and WP0, WP1, and WP3 still hold 4 seconds each.PatrolRouteon Guard_2this[index]float this[int index]index02linked_waypoint_indexvalue012linked_waypoint_pause_seconds4 s4 s4 s12 s4 seach waypoint’s idle pauseindex 0 · WP0 is the addressed entrythe index moved to 2, nothing was writtenwrite · WP2 ← 12 · the other three stay at 4
One index argument picks one entry. The write lands there and nowhere else.
The member picker on PatrolRoute filtered to the indexer row: float this[int index] with get and set, its chips reading Read · Write and 1 index arg
Figure 1. The picker lists an indexer under Properties with its full signature. 1 index arg says how many values you owe it; Read · Write says which directions its declaration allows.
The rail after choosing the indexer: Member name reads this, Arguments holds one row for index with Blackboard chosen and linked_waypoint_index picked, Binding has Direction on write
Figure 2. Member, then Arguments, then Binding. The index row sits ahead of the direction because the entry has to be chosen before anything can move.

The walkthrough adds a property node to Guard_2’s patrol in Dungeon Heist. Any component with a public indexer works the same way.

  1. Open Assets/_Project/Behavior/Guard2.bqbehavior in Static, select the patrol Sequence, click + on its row, and choose property under ACTIONS.

  2. In Target, choose Reference, click Target type, and pick PatrolRoute. In Play Mode the game fills Object with Guard_2’s own Route_NorthEast; in Edit Mode the row says no Agent runs the graph yet, which is fine for authoring.

  3. Click Member > Change, open Properties, and type this. The one row left is float this[int index] { get; set; }. Pick it. The Member card’s Name row now reads this, and an Arguments card appears with one row, index int.

  4. On the index row choose Blackboard and pick linked_waypoint_index. The variable picker offers only int variables; everything else is struck through with the reason.

    The variable picker for the index argument: its header reads Can provide int, alarm_tier and linked_waypoint_index are offered, while the Stimulus, AlarmLevel and float variables above them are struck through with the reason that argument 0 requires that exact type with no conversion
    Figure 3. An index takes its exact type. The picker says so on every row it rules out: a float value is not int, and argument 0 requires that exact type with no conversion.
  5. In Binding, choose write. The Blackboard row names the node’s own surfaced value, Item until you rename it in the Blackboard panel’s Member bindings list. The card on the canvas now shows both ends: the index it reads and the value it writes.

    The node card on the canvas, titled set waypoint pause, listing linked_waypoint_index as its read and selected_waypoint_pause as its write, tagged ACTION · PROPERTY
    Figure 4. The node card on the canvas, titled set waypoint pause, listing linked_waypoint_index as its read and selected_waypoint_pause as its write, tagged ACTION · PROPERTY
  6. Press Cmd/Ctrl+S. Saving regenerates the member provider, which is what lets Play Mode compose the new binding.

An indexer does not need a node. Guard2.bqbehavior binds PatrolRoute.this[int] at graph level, with no node of its own, and surfaces the written value as linked_waypoint_pause_seconds. Open the graph in Static with nothing selected, expand that row under Member bindings, and it states its type and direction: BLACKBOARD → MEMBER · PatrolRoute.Item. The index it uses, linked_waypoint_index, is recorded in the graph file beside it.

The expanded linked_waypoint_pause_seconds row in the Blackboard panel’s Member bindings list: float, System, @mscorlib, then a BLACKBOARD → MEMBER chip beside PatrolRoute.Item
Figure 7. The expanded linked_waypoint_pause_seconds row in the Blackboard panel’s Member bindings list: float, System, @mscorlib, then a BLACKBOARD → MEMBER chip beside PatrolRoute.Item

In Live that same binding is a card with a writable Current row, because its direction is write. Type a number and the running guard’s route changes at once, at the waypoint the index names and at no other. The card’s Source row then reads runtime edit with the number you typed, and its details name the exact member it reached: PatrolRoute.Item, direction blackboard → member.

The Live member card for linked_waypoint_pause_seconds on Guard_2 holding 12, its details open: Type System.Single, Target PatrolRoute.Item, Direction blackboard → member, Source runtime edit · 12, Health Healthy
Figure 8. The proof sits in the route itself. Select Route_NorthEast in the Hierarchy and its Waypoints list reads 4, 4, 12, 4: one entry took the twelve, the other three still hold their authored four.

Result

Success
The access completed on the addressed entry: a read filled the variable, a write reached the indexer, a condition's comparison held.
Failure
The comparison did not hold, or the target did not resolve this evaluation. An indexer that throws for its index is a recorded fault, never an authored Failure.
Running
Nothing here waits. An indexer access finishes inside the evaluation that started it.

The index

  • One Arguments row per index parameter, in declaration order, each with exactly two sources: Constant or Blackboard. There is no Default and no Project for an index.
  • An index argument must match its parameter’s type exactly. No widening, no enum to int, none of the conversion set that ordinary arguments enjoy. A float variable is never offered for an int index.
  • A Blackboard index is read again on every evaluation, so a changed variable addresses a different entry on the next tick with no rebind.
  • An index outside the collection’s range is the indexer’s own business: PatrolRoute asserts, your component may throw, and a throw is recorded as a fault for that evaluation. Nothing clamps or redirects it.

The accessors

  • The picker shows what the declaration offers: { get; set; }, { get; }, or { set; }, and the row’s Read · Write chip says the same thing.
  • A direction the declaration cannot serve is blocked on exactly that direction. A getter-only indexer blocks write and two-way; a setter-only indexer blocks read and any member condition. The Binding card reads ACCESSOR UNAVAILABLE, names the missing accessor, and offers Choose Read or Choose Write to switch to the direction that exists, plus Change property. A member condition has no direction to switch, so it offers only Change property.
  • two-way needs both accessors. It never degrades to a one-way binding when only one exists.

Identity and saving

  • Same-named indexers that differ by index count, order, or type are different members. The picker lists each with its own signature, and the graph file records the exact one you chose.
  • Saving and reopening restores the ordered index tuple as authored: each row’s source, its constant, or its variable name stays paired with its parameter. An unchanged reopen never rewrites the file.
  • Every admitted index shape authors through the same row. An in index parameter gets an ordinary row. A trailing params index parameter gets one required row holding a single array-typed Constant or Blackboard value, never the multi-value rail a method’s params parameter offers.

On the entity path

  • An indexer binds on entity agents when its accessor is a direct pass-through to one stored unmanaged container on the component: a FixedList32Bytes<float> field behind this[int index], a FixedString, any conforming unmanaged struct, or a fixed buffer.
  • A container-backed indexer also needs a public Length or Count property on the same component that reads that field’s own length; the generated access bounds-checks against it and reports an out-of-range index as a fact instead of touching memory. A fixed buffer has its element count in its declaration, so it needs no Length.
  • A params index, a managed index type, or an accessor that computes rather than forwards is refused on the entity picker with that reason, and the GameObject path is named as the way to bind it.

When it goes wrong

SymptomCheckFix
The variable I want is not offered for the index.Compare its declared type with the index parameter type. The picker strikes through every mismatch and says why.Declare a variable of the exact index type. An index takes no conversion, so an int index needs an int.
The Binding card reads ACCESSOR UNAVAILABLE.Read which accessor it names. The declaration has no setter for a write, or no getter for a read or a condition.Click Choose Read or Choose Write to take the direction that exists, or Change property, or add the accessor in C#.
Two-way is refused on an indexer that has a getter.A two-way binding needs both get and set on the same indexer.Add the setter, or choose read.
The node faults instead of running.Open Live and read the index value. It is probably outside the collection, and the indexer threw.Clamp or validate the index in the code that writes the variable. The binding passes it through as written.
I changed the index and the old entry kept the value.That is the rule: a write changes the entry it addressed and leaves it there.Write the old entry again with the value you want before moving the index on.
The entity picker refuses an indexer that the GameObject picker accepts.Read the reason on the row: a params index, a managed index type, a computing accessor, or a missing Length or Count.Forward one stored unmanaged container and expose its Length or Count, or bind it on the GameObject path.
Full-size image