Download

I need help with a variable that keeps dropping back to 0

Greets! I am trying to add child actors after 10 tiles are spawned.

When I watch the variable with debugger, TileCount shows 0, follows False, Adds 1 to TileCount. Next time through, TileCount is back to 0, follows False, and Adds 1, repeat, repeat, repeat. I do not have code zeroing out TileCount.

I tried the variable as Local, I made the TileAdd a simple function, I split the Get TileCount into 2 separate Gets, no matter what I try it resets back to 0 everytime through the blueprint. I use this same schematic with other variable in other blueprints and those are working fine.

I am losing handfuls of hair and many hours of sleep.

I am not new to programming nor am I an advanced programmer but I am new to UE4, any help would be much appreciated!

88a7b012c696b5ca73ecd1bf549e0dd76ae3d98e.png

When the Construction script is run it resets everything to its default value then goes through your custom script.
So if the default “Tile Count” value is 0 then when you place the actor in the level it will : ConstructionScript>Branch(TileCount>9)>False>Set(TileCount = TileCount+1)> Then the construction will end. So the final value of “TileCount” will be 1.

The construction script runs anytime The actor is placed, a default variable is changed in the editor or the actor is moved, scaled or rotated

Thanks! I suspected it was something like that.