Download

Get Play Number Of Clients

I’m trying to detect how many PIE clients are currently running so that I can automatically join the PIE clients to a team/class without having to do it manually.

Looking at the Engine source I see the following code should get the default LevelEditorPlaySettings ULevelEditorPlaySettings | Unreal Engine Documentation



ULevelEditorPlaySettings* PlayInSettings = Cast<ULevelEditorPlaySettings>(ULevelEditorPlaySettings::StaticClass()->GetDefaultObject());
int32 NumberOfClients = 0;
PlayInSettings->GetPlayNumberOfClients(NumberOfClients);


I’ve included “LevelUtils.h” and “LevelEditor.h” but I’m getting the following compile error:

error LNK2019: unresolved external symbol “__declspec(dllimport) public: static class UClass * __cdecl ULevelEditorPlaySettings::StaticClass(void)” (_imp?StaticClass@ULevelEditorPlaySettings@@SAPEAVUClass@@XZ) referenced in function “class ULevelEditorPlaySettings * __cdecl Cast<class ULevelEditorPlaySettings,class UObject>(class UObject *)” (??$Cast@VULevelEditorPlaySettings@@VUObject@@@@YAPEAVULevelEditorPlaySettings@@PEAVUObject@@@Z)

Might anyone be able to help me understand what other headers I would need?

Have you added “UnrealEd” to the DependencyModuleNames in your Build.cs?
Also you can do


ULevelEditorPlaySettings* PlayInSettings = GetDefault<ULevelEditorPlaySettings>();

for simplicity.

cbuttner, thanks a bunch that worked

Is there anything I can read to understand what exactly is going on when I include ‘UnrealEd’ in the PrivateDependencyModuleNames in Build.cs? Or would anyone mind explaining?

I found an odd issue where trying to ‘Generate Visual Studio Project Files’ causes the following error:

Discovering modules, targets and source code for game…
ERROR: Exception thrown while processing dependent modules of ShooterGame
Exception thrown while processing dependent modules of UnrealEd
Exception thrown while processing dependent modules of AnimGraph
Exception thrown while processing dependent modules of GraphEditor
Exception thrown while processing dependent modules of KismetWidgets
Exception thrown while processing dependent modules of BlueprintGraph
Exception thrown while processing dependent modules of KismetCompiler
Exception thrown while processing dependent modules of MovieSceneTools
Exception thrown while processing dependent modules of AssetTools
Exception thrown while processing dependent modules of TextureEditor
Exception thrown while processing dependent modules of MainFrame
Exception thrown while processing dependent modules of DeviceProfileEditor
Exception thrown while processing dependent modules of LevelEditor
Exception thrown while processing dependent modules of WorldBrowser
Exception thrown while processing dependent modules of MeshUtilities
ERROR: Couldn’t find module rules file for module ‘nvTriStrip’.

Removing ‘UnrealEd’ from PrivateDependenyModuleNames fixes this, am I missing some other dependencies?

This solution fixed my problem: Custom Animation Node - Missing nvTriStrip module? - UE4 AnswerHub

Not sure if this can be fixed/avoided in future versions?