Execute Console Command not working in Construction Script

Hello everyone, thanks for your attention.

I am currently writing a blueprint only graphic settings menu (hopefully to be submitted to the marketplace in a few days) in which I would like to be able to execute console commands in the constructor graph which doesn’t seem to work.

The reasoning is that I want to give an option that lets people tweak their graphic settings inside of the editor and assign them to certain save files just like my menu currently allows for in PIE in case they wanted different settings for different scenes while working on their levels. This will not only help people with graphics profiling but also give more control over graphics settings inside of the editor than the engine scalability settings allow for.

My analysis is that, since command lines are routed through player controllers (even if a certain reference is not specified) executing them in a construction script doesn’t work since the constructor script fails to find the necessary controller reference given that a player doesn’t exist in the construction phase inside the editor. However I keep thinking that there should be a workaround for it since it is basically the same thing as actually writing the commands in the console when in the editor. Maybe I’m overseeing something very simple here, such as a reference to plug to the execute node’s “specific player” pin.

To sum up I would like to find a way of executing console commands in construction scripts if it can be done; and if it can’t be done I would like to be sure so I try implementing the same functionality by other means.

You can check this behavior easily by creating an actor blueprint, assigning an “execute console command” node to its construction script, entering in a command line (naturally I’m working with the r. commands but any other won’t work either), dropping this actor in your level and doing anything that fires its constructor such as moving it around. This is present in both 4.6.1 and 4.7 preview. Sorry for the long wall of text, wanted to be specific : ) Thanks in advance !

Hi k.alpha,

I don’t believe the construction script of an object would be the best place to implement this feature. A construction script is only updated on move, rotate, and scale while in the editor, not during play. The only time it fires during play is when the object is spawned in. Both of these methods are working correctly in 4.6.1 & 4.7.0.

To test this:

  • Set the blueprint to execute a ‘Stat FPS’ console command.

  • Don’t place it in the level, spawn it through your character blueprint.

  • With each spawn during play the Stats will toggle.

I suggest creating this functionality in a level, widget, or game mode blueprint.

Cheers,

TJ

Hey TJ,

Thank you for answering, correct as your answer is it doesn’t exactly help my case so allow me to rephrase : Is there a way I can issue console commands using blueprints while inside of the editor and NOT in a play session ? I have all my menu functionality currently working in play already, I am looking for a way to allow execution of console commands inside of the editor while designing levels since I believe it would help level designers and people without the required console commands knowladge; as an addition to the already existing quick scalability settings.

To give a basic example I want the following bit to work properly that makes use of a public “Toggle FPS” bool that functions as a button, following your stat fps command mention :

You’ll see that after placing this actor in your level, choosing its instance for debugging, selecting it from the scene outliner and “pressing” the public bool in the details tab of this actor the execution pin is correctly fed yet the node doesn’t function.

I believe there should be a way of making it work since what I want is simply the same as manually entering a command line in the console. I’m thinking the problem lies within the way blueprints route the “execute console command” node which is through a player controller since there isn’t a player present in the editor.
Let me know what you think, thanks for your time : )

I see what you mean now, I’m sorry I misunderstood. The in-editor console commands aren’t executable in this way. The ‘Execute Console Command’ node will only work with the ‘in-game’ console commands during play.

What you are essentially trying to do is extend the editor. Which is something that we encourage, but at the moment however the only way to do this is through C++ via plugins. We recently had a Twitch stream on just this functionality.

We had an experimental feature early on that would allow users to build editor tools through blueprints but it it was taken out of the editor just after beta because it wasn’t working as intended. This is something that our devs would like to see make it into the editor again, eventually.

No problem at all : ) I could have better explained myself since my initial idea was implementing plugin functionality with Blueprints like you’ve said.

What you are essentially trying to do is extend the editor.
-Exactly ! I wanted to try this without c++ so people sticking only to Blueprints would be able to tweak them as well.

It would definitely be a handy feature and I’m sure the brilliant dev team over at Epic will find a way for it eventually, thanks for the info.

This resolves my question, I needed to know for sure that it couldn’t be done. I will submit my content without such a feature then and start writing a plugin for it (thank you for the stream as well, I hadn’t come across it before and it certainly is a usefull one) .

Keep up the good work !

Hi k.alpha I wanted the same, and after a little research I found you can call it from GEditor:
#if WITH_EDITOR
UWorld* World = GEditor->GetEditorWorldContext().World();
if (World)
{
GEditor->Exec(World, *Cmd, *GLog);
}
#endif

you’ll need include UnrealEd.h, I made my own inside a Blueprint function library class

Hi, would there be any other link to the tutorial? As the one on Twitch does not work anymore.