Dear Friends at Epic,
Here’s what I’ve done that works!
- Register new console commands in PlayerController post being play
- override GameEngine to respond to custom console commands
(UGameEngine::Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar ))
- Edit config file to use custom game engine
- call console commands in-game, they work!
#Related Working Code
;~~~ Game Engine ~~~
[/Script/Engine.Engine]
GameEngine=/Script/Solus.SolusEngine
#PIE Doesnt Work With Game Engine
First of all, PIE doesn’t work with my above setup, but it really should shouldn’t it? PIE is supposed to simulate commandline game! And Hourences only wants to work in Editor PIE, not from commandline like I do.
So I need to get him access to the console commands somehow!
They work great in commandline version of the game!
#What I tried
I tried overriding Unreal Ed Engine, assuming that PIE would use that
I added consolec ommands in Engine Init, and overrode the Exec
UUnrealEdEngine::Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar )
PIE did not recognize the new console commands!
Then I added the console commands via BP node, and now they show up in PIE and I can TAB auto complete
but when I run them,
PIE still can’t find them!
So what version of the
Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar )
Is PIE using?!
I overrode both UGameEngine and UUnrealEdEngine and neither one worked in PIE!
Let me know!
Thanks!
Rama
#More Code For Reference
I am receiving custom console commands successfully by overrideing GameEngine::Exec and using custom game engine in config file:
/*
By Rama
*/
#pragma once
#include "SolusEngine.generated.h"
UCLASS()
class USolusEngine : public UGameEngine
{
GENERATED_UCLASS_BODY()
/** Called at shutdown, just before the exit purge. */
//virtual void PreExit();
//Exec
virtual bool Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Out=*GLog ) override;
};
#CPP
bool USolusEngine::Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar )
{
bool Claimed = Super::Exec(InWorld,Cmd,Ar);
//~~~~~~~~~~~~~~~~
if (Claimed)
{
return true;
}
//custom console command
if( FParse::Command(&Cmd,TEXT("solrs")) )
{
SCC_solrs();
return true;
}
//Not captured
return false;
}