Create Custom Console Commands?

I’ve tried both the Answerhub and the official documentation, but to be honest none of the answers i’ve found are particularly easy to follow nor give me the answer to my question. I want to be able to set the value of a float variable in my custom UObject class, via the console. I’ve tried to expose a function to the console, but have had zero luck with getting it to take input. For example:



UFUNCTION(Exec)
void SetTLESpeed(float NewSpeed);


The function appears in the console, but I can’t seem to find any way to actually pass in a new speed variable. Any ideas?

In my game a have defined the function like this:



UFUNCTION(exec)
virtual void SpawnZombies(int32 Amount);


And it can be called in game by using command SpawnZombies Amount, in example:
SpawnZombies 20

Make sure you call it without parenthesis.

Odd… tried that and it didn’t work. Perhaps it’s showing up in the Console but not actually executing in my case.

As far as I know exec functions can be defined only in specific classes, that is not all classes can have exec functions. Perhaps you are defining an exec function in a class which cannot have execs?

Try declaring your function in game mode.

Yup seems like that’s the case, a derivative of UObject doesn’t allow it it seems.