多人游戏调试

由于一份代码,可以同时作为服务器和客户端,因此,要使用源代码调试功能的话,应该尽量将服务器功能和客户端功能分开来调试,原则上一次只调试一边。
以下方式调试时,最好事先将Editor Preferences->Level Editor->Play->Multiplayer Options->Run Under One Process置为false,即去掉勾选。
当要调试服务器功能时:
当要调试客户端功能时:
或许还可以参考一下:Testing and Debugging Networked Games

命令行启动参数

UE4Editor.exe "%GameDir%\MyGame.uproject" TestMap_Main -game -server // 后台运行TestMap_Main地图ds进程 注:没有命令行窗口

多人网络游戏的GameMode的API调用和Event触发顺序

World.cpp >>>
AGameModeBase::InitGame - C++

Actors PreInitializeComponents()
	AGameModeBase::PreInitializeComponents()
		AGameModeBase::InitGameState() - C++

World.cpp >>>
AGameModeBase::PreLogin - C++
UWorld::SpawnPlayActor()
	AGameModeBase::Login() - C++
		AGameModeBase::SpawnPlayerController() - C++
		AGameModeBase::InitNewPlayer() - C++
			AGameModeBase::FindPlayerStart() - C++/BP
				AGameModeBase::FindPlayerStart_Implementation()
					AGameModeBase::ChoosePlayerStart() - C++/BP
			SpectatorOnly!=1 ? AGameModeBase::MustSpectate() - C++/BP
			AGameModeBase::ChangeName() - C++
				AGameModeBase::K2_OnChangeName - BP. Alias: OnChangeName
	AGameModeBase::PostLogin - C++。第一个可以在PlayerController上安全RPC的地方或时机。
		AGameModeBase::GenericPlayerInitialization()
			AGameModeBase::InitializeHUDForPlayer() - C++/BP
		AGameModeBase::MustSpectate() - C++/BP
		AGameModeBase::K2_PostLogin() - BP. Alias: OnPostLogin()
		AGameModeBase::HandleStartingNewPlayer() - C++/BP
			AGameModeBase::HandleStartingNewPlayer_Implementation()
				AGameModeBase::MustSpectate() - 见上
				AGameModeBase::PlayerCanRestart() - C++/BP
				AGameModeBase::RestartPlayer() - C++
					AGameModeBase::FindPlayerStart() - 见上
					AGameModeBase::RestartPlayerAtPlayerStart() - C++
						AGameModeBase::MustSpectate() - 见上
						if-else ? AGameModeBase::GetDefaultPawnClassForController() - C++/BP
						AGameModeBase::SpawnDefaultPawnFor() - C++/BP
							AGameModeBase::SpawnDefaultPawnFor_Implementation()
								AGameModeBase::SpawnDefaultPawnAtTransform() - C++/BP
						if-else ? AGameModeBase::InitStartSpot() - C++/BP
						if-else ? AGameModeBase::FinishRestartPlayer() - C++
							if-else ? AGameModeBase::K2_OnRestartPlayer() - BP. Alias: OnRestartPlayer
							
Controller.cpp >>>
AController::Destroyed()
	AGameModeBase::Logout() - C++
		AGameModeBase::K2_OnLogout() - BP. Alias: OnLogout




UGameplayStatics::ParseOption() - 调查支持哪些参数