but the problem is when calling the command in the console without argument, it says “Bad or missing property playerName”.
I’ve tried switching to another type for fun, with an int32, and everything works fine. So it seems to affect some types only.
I’m looking for more info about it, I’ve checked the engine source code and there’s a console command called BugIt that also has an optional FString argument and when using it without any argument, it also displays the same error “Bad or missing property X”.
If anyone could enlighten me, it would be appreciated, thanks!
Or, pass by value instead of reference (i.e. drop the &). You incur a penalty in that the string will be copied, but if it’s something like a console command which rarely executes then I doubt that really matters.
I’ve been having issues as well receiving the parameter not parsed error as well when using default params in UFUNCTION-decorated functions. I tried global static variables, static member variables, preprocessor defines and nothing seems to want to parse. Not sure if something changed recently but I’ve never had such problems in the past and I don’t think I’m doing anything different than I normally have. Weird.
Have you tried this? This is not valid c++ code and wont even compile. You cannot take a reference from a temporary.
The ACTUAL problem is not a c++ problem. Its an Unreal Header Tool problem.
The header tool processes the parameter name and the assignment as if they were both the parameter name… And then it complains…
You cannot provide defaults parameter values for UFUNCTION()'s.
The (exec) has nothing at all to do with a linked function. It is looked up and called dynamically and programatically. There is NO WAY for the c++ linker to KNOW where that is going to occur.
(BlueprintCallable) has the same issue.
If you dont like EMars solution.
you can also create 2 versions… on with the parameter, one without.
What Epic should do, (and at one point I had my own code to do this), is provide for a means to get that data to the execution stack. Like so: