
Modifying variables inside a function
Hello,
Modifying variables inside functions is some sort of black magic for me, the main issue being that I can't always tell if the variable will keep the same value inside and outside of the function. I have some basic understanding of things like get copy/ref, pass by ref, but practically I'm getting a bit lost with all possible use cases. So first if you have some resources to share so I can learn more on the topic that would be great.
Now my current issue. I'm making a Tetris clone (you have to start somewhere) and I'm struggling to understand what is going wrong with my SpawnTetromino Function.
https://blueprintue.com/blueprint/c_5mfmf5/
"Tetromino" is a variable on the BP which execute the function. It is an array of 4 structures (one for each cube of the tetromino) containing integers (= coordinates on the grid) and a linear color.
I'm using the Spawn Row and Column that I have set manually in the structure to "spawn" the tetromino in an array of Widgets (gridslots) which represents the grid/playfield.
Then I'm using the "spawn coordinates" to set the "current coordinates" of each cube of the tetromino.
Problem: the value is correct inside the function (print string shows updated value) but not in the main event graph after it has been executed (still the default value). And I don't understand why.
As far as I understand it. "Set member in Struct" use a ref (losange pin) so it should change the value back in the array.
Any help welcomed!