From int main () to BeginPlay: how Unreal Engine initializes under the hood

β€” . , , : , . , , . 





Unreal Engine, . β€” GameMode InitGame. Actor Component BeginPlay Tick . , : .





Unreal Engine : , , . , GameFramework: , GameMode, GameState, PlayerController, Pawn PlayerState.





β€” , .





Unreal Engine , β€” . , .





, , , , - , , . , , .





, , . , , 20 : , .





, , . : , . , InitGame BeginPlay , , .





, .





Launch, , . , GuardedMain Launch.cpp. - .





FEngineLoop:





, PreInit, , , . , .





PreInit β€” , . C++, .uproject .uplugin LoadingPhase, .





. , , - . , , , .





PreInit, Unreal Engine, . , , , . Unreal Engine .





, . , , . , , , - .





?





UObject, . , CDO, . CDO β€” , .





, (Actor), , - , UCLASS, , , CDO . , , : , - .





StartupModule , ShutdownModule, , .





, Engine , , . PreInit , Init. , , UEngine:





, , . , , , . . 





β€” , Engine. Engine.h, UEngine, UEditorEngine, UGameEngine.





FEngineLoop , , GameEngine . UEngine, GEngine, ​​ Engine/Engine.h.





Engine, . , , . Engine . 





Engine? , , Browse LoadMap. , , , , UEngine.





Engine URL-, , . URL- . DefaultEngine.ini , . , , URL- , open .





, Engine. : GameInstance, GameViewportClient LocalPlayer. , LocalPlayer β€” , , GameViewportClient β€” : , , .





UGameInstance Unreal 4.4 UGameEngine , , Engine.





, Engine GameInstance, GameViewportClient LocalPlayer. : LoadMap. LoadMap UWorld, , , , ​​GameFramework, , , , , , . 





, , . : , , , .





, LoadMap, . β€” , GameMode, GameState PlayerController, β€” , . seamless travel, , . , , , , , , .





, , LoadMap. , , , .





, , . , , . , . 





, World . (World Context). Engine, , , , . - GameInstance , , .





UWorld.





, UWorld ULevels, . , , , .umap. LoadMap . , , WorldSettings .





World, .





GameInstance, GWorld. WorldContext, β€” Game, β€” . InitWorld , , , .





SetGameMode, GameInstance GameMode. , β€” , .





InitializeActorsForPlay. , Engine Β« Β». World . . 





ActorComponent Actor, :





  • , ;





  • OnRegister, ;





  • PrimitiveComponent FPrimitiveSceneProxy, FScene, UWorld.





World InitGame GameMode. GameMode GameSession. , , . . PreInitializeComponents . β€” , .





GameMode β€” , , PreInitializeComponents. GameMode GameState , GameNetworkManager, , , InitGameState.





, , InitializeComponents, β€” PostInitializeComponents. InitializeComponents :





  • bAutoActivate, ;





  • bWantsInitializeComponent, InitializeComponent. 





PostInitializeComponents β€” , , , .





LoadMap : , , , : GameMode , -. , , . GameSession GameNetworkManager . , . - GameSession - (, Steam PSN).





GameState , , : , , , .





, , , , , , β€” , .





LoadMap LocalPlayers, GameInstance: . LocalPlayer SpawnPlayActor. , PlayActor PlayerController: PlayerController. LocalPlayer, , , PlayerController β€” .





LocalPlayer Player. Player NetConnection, , .





, , . GameMode. PreLogin GameMode : . , Login. Login PlayerController .





, , , . , PostInitializeComponents PlayerController, , , PlayerState.





PlayerController PlayerState GameMode GameState , ( ) , , ( ). 





PlayerController World Player. PostLogin , , . Pawn PlayerController PostLogin. Pawn β€” , Controller. PlayerController β€” Controller. AIController, .





Unreal: , , β€” -, , , , , β€” . Controller β€” , , Pawn β€” . , , GameMode Pawn PlayerController.





PlayerState , , GameMode, . GameMode Pawn, PlayerController SpectatorPawn, , .





PostLogin , Β« Β». : , Pawn : ​​ β€” , . PlayerController , , Pawn. RestartPlayer: PlayerController , , Pawn, , Pawn , .





PlayerStart, , . GameMode.





, Pawn PlayerController, . , LoadMap, . , β€” BeginPlay. Engine World, World GameMode, GameMode WorldSettings, WorldSettings, , .





BeginPlay, , , BeginPlay , Blueprints BeginPlay. , LoadMap , .





:





, , . main, . , , .





, . , , . , LoadingPhase, PreInit.





, UObject, . StartupModule , , , , .





. , Engine, , . , GameInstance GameViewportClient, LocalPlayer GameInstance. .





, , GameInstance , . 





LoadMap. , : , , World Level. , GameInstance, , GameMode. , . , . , GameMode, , , GameSession. .





PreInitializeComponents : GameMode, GameState GameNetworkManager, GameState. : InitializeComponent (, , Activate) , , .





, LocalPlayer . PlayerController, , , PlayerState PlayerState GameState. 





GameSession . PlayerController, LocalPlayer. PostLogin, , , , , , , . , Pawn , . Pawn, PlayerController, , Pawn.





, , , β€” BeginPlay. BeginPlay , BeginPlay , , , BeginPlay Blueprint. , .





, :





  • GameModeBase GameStateBase, GameMode GameState. Unreal 4.14, Unreal-Tournament . GameModeBase , GameMode «» , BeginPlay. β€” , , .





  • Pawn, GameFramework Character, Pawn, . Character , , , , . CharacterMovementComponent, Character . , . CharacterMovement , , , .





, , C ++, , , Unreal. , , , .





, , ( UWorld ULevel):





, Unreal Game Framework, , -, . , , . , Game Framework .





, , , , GameInstance, GameInstance . , , , .





, , - , , .








All Articles