Engine Components at Work
Let’s take a closer look at how these components work together during gameplay (see FIGURE 1.18). When you start an Unreal Engine-based game, each engine component is initialized. (This is like starting your sports car: It’s idling, waiting for your input, shifting into gear, flooring the gas pedal, turning the steering wheel, or whatever else you have in mind.) Initialization takes place during the loading time between launching the game and seeing the opening title screen.
Figure 1.18 Unreal Engine component interaction
Now the engine components start communicating with one another. At startup, the core engine initializes the graphics engine, the sound engine, the physics engine, and the UnrealScript Interpreter. The core engine also begins sending commands to each component. Some components, such as the physics engine, begin sending data back to the core engine, keeping everything in sync. Once all components are initialized, the game’s user interface is displayed, and the engine waits for the player’s input.
To start the playable part of the game, the core engine loads a level that contains all assets needed for gameplay: textures, materials, sounds, meshes, animations, scripts, and so forth. Each asset is routed to the proper engine component. Materials are processed by the graphics engine, while rigid body objects are calculated by the physics engine. The event queue now “comes to life” and is quickly populated with events the core engine needs to manage as it delivers the gaming experience.
To summarize:
Game initialization:
- The core engine initializes each engine component.
- Components begin sending data back to the core engine for synchronization.
- Game is ready for user input.
Game launch (choosing and starting a level):
- A map is loaded, containing all game assets and their corresponding properties.
- Each asset’s information is routed to its respective engine component.
Gameplay (excessive use of flak cannons, shock rifles, and weapons):
- Each engine component sends information to the core engine, which is sorted as a series of prioritized events in the event queue.
- The Unreal Engine’s game loop runs constantly, evaluating each event by priority and performing the highest-priority tasks first.