liveBook · Manning

Data flow

As explained in High Performance Unity Game Development

The directed movement and transformation of data through the stages of a software system.

A new enemy that teleports when hit could force another branch into an enemy inheritance tree. A data-flow approach asks a simpler question: what data does teleporting read, what does it change, and which system needs the result? Gameplay becomes a sequence of transformations from input data to output data, rather than a chain of object relationships. section 1.3

In a survival game, each system needs a different slice of enemy data:

  • Movement reads position, direction, and velocity to produce a new position. section 1.3
  • Tracking reads enemy and player positions to produce a new direction. Teleporting reads position, damage, and teleport-on-hit state to produce a position. section 1.3
  • Rendering reads the resulting position and a Unity GameObject, moves the GameObject, and lets Unity render it there. section 1.3
Listing 1.7 Class holding all the data for our enemies
public class EnemyData
{
    public Vector2[] Position;
    public Vector2[] Direction;
    public float[] Velocity;
    public bool[] TeleportOnHit;
}

The EnemyData listing stores positions, directions, velocities, and teleport-on-hit flags in separate arrays. This makes each kind of runtime data available together, while systems can process only what they need. section 1.3

Composing an enemy from behavior objects avoids a rigid inheritance tree, but the behaviors still need overlapping, different data. Splitting them into ever-smaller objects adds references and relationships without grouping positions or velocities in memory. Separating data from logic instead makes a feature’s required data, transformation, and path through the game explicit. Use that clarity where it helps; data flow is an architectural guide, not a reason to multiply systems without a need. section 1.3 section 1.1

How High Performance Unity Game Development covers it

How deep it goes
Works through movement, tracking, teleporting, and rendering inputs and outputs, with an array-based data listing; does not show complete system implementations.
Examples
Uses a moving enemy, player tracking, teleport-on-hit behavior, and GameObject positioning to trace successive data transformations.
What it assumes
Introduces input–transformation–output from enemy examples while using C# classes and Unity GameObjects without explaining those APIs from zero.
What you can do after
Apply it by identifying a gameplay feature’s required data, transformation, and output before adding behavior to an enemy system.
How it connects
Connects data-oriented design to separation of data and logic, object composition, inheritance, and Unity rendering.

Also explained in

Compare how 4 books explain data flow →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of High Performance Unity Game Development. The section links point to the parts of the book it draws on.