Variable resetting to default value

Hello,
I’ve having a little bit of trouble with a variable. In my project, I use a boolean variable as a sort of “Do it once” node, but with a kinda expanded functionality. The problem is, it does not work as expected; I debugged, as per usual, however, when I was debugging, I found a rather awkward behavior. Let me explain and add some screenshots:

I created a new variable called “Do Things” (Erased the old, which was a boolean, and created this variable to make a clean test) on which I store an integer value, with a default value of ‘69’

When a thing happens, I update the value with a new value, ‘3’ in this case. Everything okay so far; the variable has ‘3’ as value

However, when I continue debugging, and advance to the next debug point, the value has changed to it’s default value, ‘69’

The variable (as is new) has no setters or getters more than those on the screenshots, so, WTF?! I just clicked on “Resume play-in-editor session”, which teleports me to the second debug point shown; the “Preview” flicks, so this second point is happening after the game does code again (Code → Game → Code).

It should be noted that this project is modifying the “First Person Template” given by Unity, and this blueprint is the one named “BP_FirstPersonCharacter”, so it may have something to do with it, although I don’t get how.

Thanks in advance!

Seems to work fine, perhaps you are changing the variable elsewhere via reference?

What node is on the left of your diagram that joins the two segments? Is it a sequence node?

Literally, after hours of trying to solve it, the problem was, that there was no problem, just a bug.
I’ve created a new Unity project with the “First Person” template, migrated everything, Ctrl C’d and Ctrl V’d without changing nothing (not even a tiny bit), and everything works correctly. I guess my project was corrupted and, somehow, it was the cause of the error.

Well then, thread resolved by mere chance :crazy_face:

Thanks for answering, but I managed to resolve it by myself. At the end, it was just a corrupted project.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.