NetworkEmulationSettings

NetworkEmulationSettings

#Overview

name: NetworkEmulationSettings

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of NetworkEmulationSettings is to provide customizable settings for emulating network conditions such as latency and packet loss in the Unreal Engine editor’s Play-in-Editor (PIE) mode. This allows developers to simulate various network scenarios and test their multiplayer game performance under different network conditions.

This setting variable is primarily used by the Unreal Engine’s editor subsystem, specifically in the Play-in-Editor functionality. It is referenced in the UnrealEd module and the Engine’s core runtime.

The value of this variable is set in the LevelEditorPlaySettings class, which is part of the editor’s configuration. It can be modified through the editor’s settings interface or programmatically.

NetworkEmulationSettings interacts with other variables related to PIE mode, such as PlayNetMode and other multiplayer options. It is used in conjunction with these settings to determine how network emulation should be applied in different play scenarios (e.g., listen server or client).

Developers must be aware that this variable affects network behavior only in PIE mode and does not impact the actual network performance of the packaged game. It’s crucial to understand that this is a testing and debugging tool, not a way to optimize real-world network performance.

Best practices when using this variable include:

  1. Use it to test your game under various network conditions to ensure a smooth experience for players with different connection qualities.
  2. Combine it with other debugging tools to identify and fix network-related issues early in development.
  3. Test both server and client perspectives by adjusting the emulation settings for each target.
  4. Remember to disable or reset these settings before packaging the game to avoid unintended effects in the final product.
  5. Use realistic values that represent your target audience’s typical network conditions for the most relevant testing.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEditorPerProjectUserSettings.ini:7, section: [/Script/UnrealEd.LevelEditorPlaySettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorPlaySettings.h:454

Scope (from outer to inner):

file
class        class ULevelEditorPlaySettings : public UObject
function     bool IsNetworkEmulationEnabled

Source code excerpt:

	bool IsNetworkEmulationEnabled() const
	{
		return NetworkEmulationSettings.bIsNetworkEmulationEnabled;
	}

	/**
	 * Customizable settings allowing to emulate latency and packetloss for game network transmissions
	 */
	UPROPERTY(config, EditAnywhere, Category = "Multiplayer Options" )
	FLevelEditorPlayNetworkEmulationSettings NetworkEmulationSettings;

public:

	// Accessors for fetching the values of multiplayer options, and returning whether the option is valid at this time
	void SetPlayNetMode( const EPlayNetMode InPlayNetMode ) { PlayNetMode = InPlayNetMode; }
	bool IsPlayNetModeActive() const { return true; }

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PlayLevelNewProcess.cpp:232

Scope (from outer to inner):

file
function     void UEditorEngine::LaunchNewProcess

Source code excerpt:

	{
		NetworkEmulationTarget CurrentTarget = (NetMode == EPlayNetMode::PIE_ListenServer) ? NetworkEmulationTarget::Server : NetworkEmulationTarget::Client;
		if (InParams.EditorPlaySettings->NetworkEmulationSettings.IsEmulationEnabledForTarget(CurrentTarget))
		{
			CommandLine += InParams.EditorPlaySettings->NetworkEmulationSettings.BuildPacketSettingsForCmdLine();
		}
	}

	// Decide if fullscreen or windowed based on what is specified in the params
	if (!CommandLine.Contains(TEXT("-fullscreen")) && !CommandLine.Contains(TEXT("-windowed")))
	{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:557

Scope (from outer to inner):

file
function     void ULevelEditorPlaySettings::PostEditChangeProperty

Source code excerpt:

	}

	if (PropertyChangedEvent.MemberProperty && PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(ULevelEditorPlaySettings, NetworkEmulationSettings))
	{
		NetworkEmulationSettings.OnPostEditChange(PropertyChangedEvent);
	}

	PushDebugDrawingSettings();
	if (PropertyChangedEvent.MemberProperty && PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(ULevelEditorPlaySettings, bShowServerDebugDrawingByDefault))
	{
		// If the show option is turned on or off, force it on or off in any active PIE instances too as a QOL aid so they don't have to stop and restart PIE again for it to take effect

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:588

Scope (from outer to inner):

file
function     void ULevelEditorPlaySettings::PostInitProperties

Source code excerpt:

	NewWindowHeight = FMath::Max(0, NewWindowHeight);

	NetworkEmulationSettings.OnPostInitProperties();

#if WITH_EDITOR
	FCoreDelegates::OnSafeFrameChangedEvent.AddUObject(this, &ULevelEditorPlaySettings::UpdateCustomSafeZones);
#endif

	for (FPlayScreenResolution& Resolution : LaptopScreenResolutions)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameInstance.cpp:425

Scope (from outer to inner):

file
function     FGameInstancePIEResult UGameInstance::StartPlayInEditorGameInstance

Source code excerpt:

		if (Params.EditorPlaySettings->IsNetworkEmulationEnabled())
		{
			if (Params.EditorPlaySettings->NetworkEmulationSettings.IsEmulationEnabledForTarget(NetworkEmulationTarget::Client))
			{
				URLString += Params.EditorPlaySettings->NetworkEmulationSettings.BuildPacketSettingsForURL();
			}
		}

		if (EditorEngine->Browse(*WorldContext, FURL(&BaseURL, *URLString, (ETravelType)TRAVEL_Absolute), Error) == EBrowseReturnVal::Pending)
		{
			EditorEngine->TransitionType = ETransitionType::WaitingToConnect;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameInstance.cpp:455

Scope (from outer to inner):

file
function     FGameInstancePIEResult UGameInstance::StartPlayInEditorGameInstance

Source code excerpt:

		{
			NetworkEmulationTarget CurrentTarget = Params.NetMode == PIE_ListenServer ? NetworkEmulationTarget::Server : NetworkEmulationTarget::Client;
			if (Params.EditorPlaySettings->NetworkEmulationSettings.IsEmulationEnabledForTarget(CurrentTarget))
			{
				ExtraURLOptions += Params.EditorPlaySettings->NetworkEmulationSettings.BuildPacketSettingsForURL();
			}
		}

		// make a URL
		FURL URL;
		// If the user wants to start in spectator mode, do not use the custom play world for now