Getting Around Constant Values At Runtime

Link to blueprint exported as text: Possible Spam Detected -

I am making a mod for MechWarrior 5 which is built with Unreal Engine 4.26. In a stroke of genius, the devs have seemingly randomly assigned the display names (text parameter) of some assets as constants in their asset parent classes. I want to force the blueprint to try to edit Name and Short Name at runtime, but it won’t package due to this error.

I discussed this with people from a Discord server about modding this game and they suggested this is unintended behavior. The value might mutable at runtime and the devs just created its parent class incorrectly. The editor could be “tricked” into packaging it. Due to the chaotic nature of this game’s code, the constant nature of a variable during compiling has no bearing on its nature at runtime. In summary, the editor thinks the code won’t work instead of just letting me package it to see if it actually doesn’t work. Is there any truth to this idea of “tricking” the editor into packaging something it thinks is invalid?

I am open to other suggestions.

Const is less so a technical specification and more of a developer guideline (at least with respects to C++). It’s not that the editor “thinks the code won’t work,” it’s that the game developers said it shouldn’t.

Though I’m not sure how they even have const in Blueprints… maybe a custom K2 node or something?
With that said, it’s trivial in C++. If that Target object class was made in C++, you can make a BlueprintCallable function and use const_cast<>().
I’m not familiar with modding that game, so I’m not sure what those types would be or how much was made in Blueprint vs C++.
The code would be something along the lines of this, but UObject being whatever type Target ended up being:

	static void SetNameInTarget( const UObject* InTarget, FText Name)
		const_cast<UObject*>(InTarget)->Name = Name;
1 Like