Quick answer: Construct picks an arbitrary family member if no condition narrows the selection. Use For each or condition-based picking before referencing a family instance variable.
A wave-defense game has an EnemyFamily containing Goblin, Orc, Troll, all sharing an hp variable. An event reads EnemyFamily.hp expecting the current enemy, but the value belongs to a random instance.
Picking Selects an Instance
Construct’s event system uses “picking” — events filter which instances apply. Without a picking condition, expressions can return any instance’s value, often the first.
Fix: For Each
Wrap iteration in For each:
- Add “System → For each EnemyFamily”.
- Inside that block, EnemyFamily.hp refers to the current iteration’s instance.
For each EnemyFamily
EnemyFamily.hp < 0
→ EnemyFamily.Destroy
For each runs the sub-events per family member, so picks are scoped to one instance at a time.
Fix: Conditional Pick
For specific instances, pick via condition:
On collision EnemyFamily with Player
→ Subtract 10 from EnemyFamily.hp
The collision condition picks the colliding enemy. EnemyFamily.hp in actions refers to it.
Pick by UID
If you stored a UID earlier and want to act on the same instance later:
System → Pick EnemyFamily by UID stored_uid
→ Set EnemyFamily.hp to 100
Useful for callbacks where the instance reference must persist (timers, async events).
Verifying
Debug overlay: print EnemyFamily.hp inside For each. Each frame shows the iteration order — verify each instance’s hp changes independently. Without For each, expect arbitrary single value.
“Pick first, read second. Family vars without picking are random reads.”
Construct’s picking is the engine’s superpower — once you internalize it, family-based architecture is incredibly clean.