In a survival game, hundreds of enemies may need to move every frame. An object-oriented design might give each enemy its own position, direction, velocity, and Move() method. Data-oriented programming instead asks what the movement calculation reads and writes, then organizes the data and logic around that transformation. It is the data-and-logic separation aspect of data-oriented design. section 1.2.1 section 1.3
Store positions, directions, and velocities in arrays; process them with functions that take the required data as input and update the positions. A loop makes the work explicit. Keeping data used together close in memory can also make more of each CPU cache line useful, reducing time spent waiting for memory rather than calculating movement. section 1.3 section 1.2.1 section 1.6
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 enemy-data listing places position, direction, velocity, and teleport-on-hit flags in separate arrays rather than inside individual enemy objects. section 1.3
Add a teleport-on-hit enemy
Start with the new behavior’s inputs: position, damage received, and whether this enemy teleports when hit. Add a function that calculates the resulting position instead of first finding a place for the behavior in an inheritance hierarchy. The same approach can set an enemy’s direction toward the player or change its velocity based on distance. section 1.3 section 1.4
For a playable Unity implementation, keep designer-set rules in Balance and changing state in GameData. Static Logic functions transform GameData using rules and input. Board handles input and displays the result; one Game script drives the loop. This makes the order of updates and the ownership of state easier to follow than independent Update() calls on many GameObjects. section 4.6 section 5.1 section 5.1.1
Preallocated arrays can serve as data pools alongside a GameObject pool. Track whether an enemy is alive in its own data array: a GameObject’s active state may change merely to hide enemies while the game is paused. Allocate capacity deliberately and validate indices. For frequent, large workloads this structure can be useful; a small menu or loading-only tool may gain little. Profile the target hardware before adding further optimization. Unity GameObjects can still handle presentation, and Burst, Jobs, and ECS are optional—not prerequisites. section 3.3.4 section 1.1.1 section 1.2 section 1.5





