Custom registered Console Commands dont work in PIE

Dear Friends at Epic,

Here’s what I’ve done that works!

  1. Register new console commands in PlayerController post being play
  2. override GameEngine to respond to custom console commands (UGameEngine::Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar ))
  3. Edit config file to use custom game engine
  4. 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;
}

You probably don’t want to be overriding the Exec function directly on UEngine, since (as you say) there is a different engine in the editor and standalone game.

You can mark any function as being an ‘exec’ function using UFUNCTION markup from your game mode (and any other class), and you will be able to execute it by typing that function name into the console. Here’s an example from CheatManager.h:

/** Return to walking movement mode from Fly or Ghost cheat. */
UFUNCTION(exec)
virtual void Walk();

Thank you so much Ben!

#:heart:

Rama

Hi

Can you assist with how you got your exec function recognized?

I get the error “Command not recognized” in the log, whether in editor or packaged game.

I have tried functions in CheatManager as well as GameMode. I have them defined with UFUNCTION(exec) too.

Something strange may be going on.

EDIT
After posting the above, I realized that the CheatManager is only valid on the server. I was attempting the commands from a client. I moved the functions directly into PlayerController and all is well now.

Glad you got it working!

Rama

Hey I used the solus tutorial. i get the autocomplete on the console but executing the command doesnt seem to work :/. im working with a blueprint project and i just added the code to a actor and then extended it with blueprint. but i doesnt work so do i have to use the playercontroller class in the c++ class and add the code to it?

I Got it working as well :slight_smile: Thanks rama for ur wiki on custom commands. however i cant get ur configuration wiki working on my project :./