Call Blueprint Event from Console

Hi,

Does anyone know of a way to bind blueprint events to console commands, mainly so I can debug a fairly complex blueprint without binding keys for each individual variable and such? Ideally I’d like to avoid using C++ at this point, but if its inevitable, so be it.

For example, I can enter a command into the console:


dock_load 1, 4

And my blueprint will run a certain event with a the arguments I supply?

1 Like

I’m just getting started in Unreal, but I’m looking to do the same thing. With the help of another forum user I’ve tracked down where to look at in the C++ sources, and so right now I’m getting the hang of making blueprint nodes. If you’re interested I can let you know when I have a blueprint node’s sources figured out. Not promising anything but I want to look into making plugins as well, so if I can figure out how to do that I’ll be able to help others avoid having to compile.

Sounds good, drop a line if you manage to figure something out.

I stumbled upon this plugin and figured I’d let you know. I haven’t actually looked into it myself yet though.

If you add an event in the level script, you can actually call it directly in the console with “ce EventName OptionalParamValue” etc.

As an example, if this were in my level script:

I could call it on the console with “ce TestConsoleEvent 25” and it would output 25 to the screen.

If you want an event in a blueprint for an actor in the world, you can use a similar setup, except you also have to specify which actor (and it uses “ke” instead of “ce”):
“ke ActorName EventName ParamValue”

If you don’t know the actor name, you can use “*” and it will try to call it on **every **actor in the world:
“ke * TestConsoleEvent 25”

16 Likes

Awesome. That sounds super useful. Thanks for the info.

this example, “ke * TestConsoleEvent 25”, it doesnt work on a shipping build, right? or am i doing something else wrong?

I think it probably is still working, as in the function is still firing, just print string does not work in shipping build.

i used " ke * " commands a bit to do various things, not print strings, and they dont seem to work. so i am wondering, are ke * left out from shipping builds? and so i have to find another way for my blueprints to communicate?

1 Like

Do you know if there is a way to get list of available top-level callable events in console in UE4.24 in shipped build?

AFAICT, “ce” works shipped, but “ke” doesn’t. Rather than mess with console commands, you can go directly to the eventual destination, “CallFunctionByNameWithArguments.” This was my first time working with C++ in any capacity, much less in Unreal, but here’s the custom blueprint I came up with. It seems to work (only tested in UE 5.0.3), but I’m sure I’ve done things in the stupidest way possible… so if someone smarter can suggest improvements, please do.

Create these files, and after changing “TEMP22” to your project name, place them in /Source/ProjectName in your project folder. Then open the solution in VS and build your project.

TestBFL.h

#pragma once

include “CoreMinimal.h”
include “Kismet/BlueprintFunctionLibrary.h”
include “TestBFL.generated.h”

//Change “TEMP22” to your project name

UCLASS()
class TEMP22_API UTestBFL : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
UFUNCTION(BlueprintCallable, Category = “Development”, meta = (CallableWithoutWorldContext))
static bool DoCallFunctionByName(FString Target, FString Command, FString Arguments);
};

TestBFL.cpp

include “TestBFL.h”
include <Runtime/Core/Public/Misc/OutputDeviceNull.h>
bool UTestBFL::DoCallFunctionByName(FString Target, FString Command, FString Arguments)
{
FString Comb;
Comb += Target;
Comb += " ";
Comb += Command;
Comb += " ";
Comb += Arguments;
const TCHAR* Cmd = Comb;
FString const ObjectName = FParse::Token(Cmd, 0);
FOutputDeviceNull
Stupid = nullptr;
UObject* ObjectToMatch = FindObject(ANY_PACKAGE, *ObjectName);
return(ObjectToMatch->CallFunctionByNameWithArguments(Cmd, *Stupid, nullptr, true));
}

When you reload the editor, the blueprint should be available as “Do Call Function By Name.”

PS, thank you to the dude who made this site: Custom Blueprint Nodes Part 1: Blueprint Libraries · /home/trashbyte

If you find yourselff here in 2023. Here is the corrected code UE 4.27 and up

FString Comb;
Comb += Target;
Comb += " ";
Comb += Command;
Comb += " ";
Comb += Arguments;

const TCHAR* Cmd = *Comb;
FString const ObjectName = FParse::Token(Cmd, 0);

FOutputDeviceNull IAmStupid;

UObject* ObjectToMatch = FindObject<UObject>(ANY_PACKAGE, *ObjectName);
return(ObjectToMatch->CallFunctionByNameWithArguments(Cmd, IAmStupid, nullptr, true));
1 Like

hey, folks, there is official documentation about calling your custom event in your blueprint at here: Custom Events | Unreal Engine 4.27 Documentation, which I think is a very clear and useful instruction!

1 Like