I have an object called MaterialPickup, that has a Enum that defines the type of pickup, and the StaticMesh is changed by that variable
Then in the editor, i have placed 3 objects of this class, each one with 1 different Enum:
You can see that in the editor, it shows the correct models, (you can also see that i created another test variable, an int that has 0, 1 and 2 setted on those 3 object)
BUT, when i run the preview, it simply collapses all my variables to the default value:
Does anyone knows what could be causing this? Any configuration i forgot?
Please, im really stuck on this issue, and i need to continue my work
Thanks in advance!
Might be an issue of when the construction script runs vs when it receives the “instance edited” variable. I believe the construction script runs first then the “begin play” stuff so the “instanced” variable isn’t initialized until after the construction script has run. Try placing your nodes from the construction script into the event graph and connect it to begin play see if that fixes it.
Thanks, but it didnt work if that was the case, the highlight text that shows “Pick up 0” would show the correct value, because it gets the value in event tick. the thing is that variables are really replaced by the default value set on the blueprint (and i really dont know why)
You must be setting those variables in the blueprint then. That should override the instance value
yeah, in the blueprint it actually has a default value, but i cant change it to “null” or “none”
So you place them in the level, and then changed the placed instances’ variables, but they revert to the default as set on on the blueprint class once the game runs?
Not sure why it does that.
Maybe you need to call the parent constructor? In an Actor blueprint (which can be placed in levels), defining a constructor function overrides the original constructor and won’t do the things its parent class did, I think. Maybe.
If you right-click the overridden function’s start node (purple node with the function’s name on it) there should be an option in the context menu of calling the parent class’ version of that function. Click that option and it should generate an orange parent class function node.
Maybe the original Actor constructor function is what initializes the instance’s variables as they’re set on the instances placed in the level? I don’t know if this will fix it but try it and let me know.
Well, i have tried your sollution, but it didnt work either I think it doesn’t really make sense, because even though the class has a parent, the variable isn’t initialized there, the variable only exists within the child class
I think i will try to just update the Unreal initializer, and update my project also to version 4.20 to see if it fixes the issue (my version is 4.19.2)
Just right now I faced the same issue and what helped me, basically was not setting up the variable in parent class and writing all the blueprint with idea that I need only to use “get” variable, and the data that is going to be “get” - is data from editor.
So @RotcivOcnarb , on your place I’d delete this “Set Static mesh” on your first screen