0
0
Unityframework~10 mins

Game engine architecture overview in Unity - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Game engine architecture overview
Start Game Engine
Initialize Core Systems
Load Assets & Resources
Game Loop Start
Process Input
Update Game Logic
Check Exit Condition
Repeat Game Loop
Shutdown & Cleanup
This flow shows how a game engine starts, runs its main loop processing input, updating logic, rendering frames, and then shuts down.
Execution Sample
Unity
void Update() {
    ProcessInput();
    UpdateGameLogic();
    RenderFrame();
}
This code runs every frame to handle input, update game state, and draw the scene.
Execution Table
FrameProcessInputUpdateGameLogicRenderFrameExit ConditionAction
1Read keyboard/mouseMove player, check collisionsDraw scene to screenFalseContinue loop
2Read keyboard/mouseUpdate NPCs, physicsDraw updated sceneFalseContinue loop
3Read keyboard/mouseCheck win/lose stateDraw final frameTrueExit loop
💡 Exit condition true at frame 3, game loop ends
Variable Tracker
VariableStartAfter Frame 1After Frame 2After Frame 3
PlayerPosition(0,0)(1,0)(2,0)(2,0)
GameRunningTrueTrueTrueFalse
FrameCount0123
Key Moments - 2 Insights
Why does the game loop keep running even though we process input and update logic every frame?
Because the exit condition is checked after processing input, updating logic, and rendering. The loop continues until the exit condition becomes true, as shown in the execution_table rows 1 and 2.
What happens if the exit condition becomes true during the game loop?
The loop stops after completing the current frame's processing, as seen in frame 3 of the execution_table where the exit condition is true and the action is to exit the loop.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the value of GameRunning after frame 2?
AUndefined
BTrue
CFalse
DNull
💡 Hint
Check variable_tracker row for GameRunning after Frame 2
At which frame does the exit condition become true according to the execution_table?
AFrame 1
BFrame 2
CFrame 3
DNever
💡 Hint
Look at the Exit Condition column in execution_table
If the RenderFrame step was skipped, what would likely happen in the game loop?
AThe game would not display changes on screen
BThe game would not update logic
CThe input would not be processed
DThe exit condition would never be checked
💡 Hint
RenderFrame draws the scene; skipping it means no visual update
Concept Snapshot
Game engine runs a loop every frame:
- Process input from player
- Update game logic (movement, physics, AI)
- Render the frame to display
Loop continues until exit condition is true
Core systems initialize before loop and cleanup after
Full Transcript
A game engine starts by initializing core systems and loading assets. Then it enters the main game loop. Each frame, it processes player input, updates the game logic like moving characters and checking collisions, and renders the frame to the screen. After rendering, it checks if the game should exit. If not, it repeats the loop. When the exit condition is true, the loop ends and the engine shuts down. Variables like player position and frame count update each frame. This cycle keeps the game running smoothly and responding to player actions.