# Private variables losing values/resetting to defaults during runtime

**URL:** <https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [June 9, 2017, 2:25pm UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091 "2017-06-09T14:25:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.dub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@j.dub](https://forums.unrealengine.com/u/j.dub)\
**Post date:** [June 9, 2017, 2:25pm UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091/1 "2017-06-09T14:25:58Z")

</div>

I have a strange issue that I can’t repro in a new project, so it is something specific to one project, but I was hoping someone might recognize a pattern and have some insight into my problem. I noticed some of my variables are being reset to default when trying to use them. The setup to repro this in my project is this.

Create enum with 2 members. create 2 variables of enum type, one private (PreviousState) and one public (CurrentState).

[![](https://i.imgur.com/i93hSJA.png) ](https://i.imgur.com/i93hSJA.png)

[![](https://i.imgur.com/rpRtDwR.png) ](https://i.imgur.com/rpRtDwR.png)

setup a function as illustrated.

[![](https://i.imgur.com/AjqOmHd.png) ](https://i.imgur.com/AjqOmHd.png)

This is a simple trap to detect variable change.

What happens is when i select Option2, the breakpoint pictured gets hit. When I switch back to Option1 it does not get hit, the PreviousState (private) variable gets reset to Option1 as soon as I change CurrentState to Option1 and the branch does not evaluate as true because they are the same. This only happens when PreviousState is private, **if i mark this variable as public, everything works normally.**

[![](https://i.imgur.com/ZSXxKsV.png) ](https://i.imgur.com/ZSXxKsV.png)

I have had another instance of this problem with an object variable, but the setup was difficult to reproduce. I’m hoping someone with some engine knowledge can shine some light on what might be going on.

this repro is BP only, but I do have c++ code and it does the same thing with a c++ enum.

Any help is appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![j.dub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@j.dub](https://forums.unrealengine.com/u/j.dub)\
**Post date:** [June 9, 2017, 9:33pm UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091/2 "2017-06-09T21:33:59Z")

</div>

Update: I spent the afternoon systematically debugging this problem, I’m not sure the exact cause, but when **I removed the /Saved/Config folder, everything started working normally.** I don’t have time to debug it down to the specific file, but it is solved.

I wasn’t aware there was anything in the Saved folder that could affect a project in that way, I have only been removing Intermediate/Binaries directories when I want to clean.

---

<div class="post-metadata">

**Author:** ![Raildex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Raildex](https://forums.unrealengine.com/u/Raildex)\
**Post date:** [June 9, 2017, 9:37pm UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091/3 "2017-06-09T21:37:47Z")

</div>

@JoeWintergreen probably knows whats up.

---

<div class="post-metadata">

**Author:** ![JoeWintergreen](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/joewintergreen/32/1194565_2.png) [@JoeWintergreen](https://forums.unrealengine.com/u/JoeWintergreen)\
**Post date:** [June 11, 2017, 11:12am UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091/4 "2017-06-11T11:12:54Z")

</div>

This is probably this bug again:

> **[\[SURVEY\] There's A Really Really Terrible Bug Where Child Blueprints Get...](https://forums.unrealengine.com/showthread.php?143060-SURVEY-There-s-A-Really-Really-Terrible-Bug-Where-Child-Blueprints-Get-Their-Variables-Reset%2Fpage2)**
>
> Since the dawn of time, or at least the dawn of UE4, there’s been a bug in UE4 which can be extremely damaging when it occurs, and where it occurs it always occurs again. I’ve seen a million answerhub threads about it but haven’t found one on the...

---

<div class="post-metadata">

**Author:** ![j.dub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@j.dub](https://forums.unrealengine.com/u/j.dub)\
**Post date:** [June 12, 2017, 7:06pm UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091/5 "2017-06-12T19:06:57Z")

</div>

This unfortunately is not the same issue I don’t believe, correct me if I am wrong. I ran into this thread a few times while debugging my issue. These variables are reset during design-time, usually when editor is closed and reopened. Mine is resetting during run-time.

So my issue with the enums seems to have been resolved, but I found another instance of a reference variable being reset to NONE at run-time again today.

it is literally, 1st frame Set VariableReference (has legit value), next frame Get VariableReference (NONE). If I make the value public, it is working fine. I might have to dig into the Saved/Config stuff a little more after all so I can get to the root of this problem. It has been a very frustrating bug.

---

<div class="post-metadata">

**Author:** ![j.dub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@j.dub](https://forums.unrealengine.com/u/j.dub)\
**Post date:** [June 12, 2017, 7:25pm UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091/6 "2017-06-12T19:25:00Z")

</div>

scratch that, my enum issue has returned as well, I’ll report back when I narrow it down again, just removing the Saved folder didn’t seem to work this time.

---

<div class="post-metadata">

**Author:** ![csisyadam](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@csisyadam](https://forums.unrealengine.com/u/csisyadam)\
**Post date:** [June 17, 2023, 10:09am UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091/7 "2023-06-17T10:09:51Z")

</div>

This is an old topic, but I experienced a similar issue. Currently using UE 5.2.

I have a variable on my camera component (full BP) that is marked as private and **not** instance editable (this is the follow target actor reference set through a function). When I start the game, everything works fine. Then I select the camera instance (during runtime) and change its location manually. After doing this, the variable mentioned above loses its value (I assume it resets to its default, which is null/none).

Marking the variable “instance editable” solves the problem, however it is not the desired behaviour, since I do not want this variable to be instance editable. 🙂

---

<div class="post-metadata">

**Author:** ![ClayBudin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ClayBudin](https://forums.unrealengine.com/u/ClayBudin)\
**Post date:** [September 20, 2024, 1:05am UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091/8 "2024-09-20T01:05:14Z")

</div>

I’m on 5.3 and this bug tripped me up.

Is anyone at Epic aware of this bug? Is it in a bug list somewhere where it could be fixed?

I will add what I’ve found to the discussion:

1. If you absolutely don’t want the variable to be Instance Editable, it seems like turning on Expose on Spawn will work as well, but it will generate a compiler warning.
2. Someone mentioned that they saw the issue on a camera. My blueprint also has a Camera Component. And it inherits from Pawn. I wonder if either of these are relevant to the issue?

Thanks

---

<div class="post-metadata">

**Author:** ![NeroTBF](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NeroTBF](https://forums.unrealengine.com/u/NeroTBF)\
**Post date:** [January 21, 2025, 8:49pm UTC](https://forums.unrealengine.com/t/private-variables-losing-values-resetting-to-defaults-during-runtime/94091/9 "2025-01-21T20:49:09Z")

</div>

> [@j.dub](#):
>
> closed and reopened

Hi,

I have the same problem with UE 5.2.1. A variable (structure variable made of String, Enumeration and Actor) is reset by default value in Child Blueprint. My best guest is the variable is reset when I recompiled the parent blueprint or when modified the variable itself (it is a structure or the enumeration included in the structure). So may be when I modified these variable, it recompiled all the blueprints (parents and childs) setting the values of variable to default. As I cannot really work around this bug, I set the variable on beginplay for each Child Blueprint and the values of the variable is stored in separated variables in each Child Blueprint.

Hope it can help.
