I would like to process some data within a BP function, based on some constants.
I added a few local variables to the function to hold these constants.
But after populating them with default values, these values get erased when the BP is compiled.
For example:
Create a BP based on Actor.
Add a BP function and hook it up, for example in the construction script.
Add a local variable to the function, say a material reference.
Add a material as default.
Compile the BP
Now you will see that the variable default value is “empty” again.
Is this a bug?
I see no reason why function variables cant have default values…?!
Hmmm that might be related to fact that Blueprints is based of UnrealScript VM and UScript didn’t have default local varables, you just assign them in function it self
I was looking into your issue and I was able to reproduce this on our end in 4.7.6, however after further testing I found that this issue has been resolved on our latest internal build. I hope that this information helps.
My current work around for some types is to use a “MakeVector”, or “make literal string” node, etc.
Just for types like MaterialInstances this doesnt work.
Ill look forward to the fix coming to the launcher versions
In 4.8.2 I am having this issue with an array of classes. It remembers the size of the array but each entry has value None. Integers remember their value. It doesn’t happen if I use a non-local variable. I cross posted this to Unreal Answers.