[BUG] Private Array gets removed if obj is moved during simulation

A non public array ( with or without checking the Private checkbox ) will gets removed ( zero-filled? ) if object is moved during simulation.

You can reproduce the step by following these nodes.

The size will show 2 until it is moved. then it will become zero.

I just found some new information , apparently default assigned values are not removed. Only those assigned during runtime will be.

Has anybody tried this?

Moved this to bug report. I’m preeeettty sure it’s a bug. Do point out if it’s not.

I’ve posted this for almost a full 2 weeks with fully reproducible steps. I’m hoping someone could get back to me on this.

Hi ,

After doing a quick test I realized my initial answer was incorrect and that this is intended functionality. You are calling the array to be build at begin play, however during simulate moving the object technically destroys and recreates the object in a new location. Once it has been moved it is getting the length of the array. However, because it is not begin play it is registering as nothing in the array. To fix this, place your add nodes in the construction script, which will compile every time you move the object.

This is to say that when an object is moved in simulate it is actually destoyred and recreated? If that’s the case, why wouldn’t this behavior be consistent when the var is set as public

As a public variable, multiple blueprints (or copies of the blueprint) can have access to it, so the array is kept in tact as long as another blueprint requires it. In the case of private variables, when the blueprint destroys and recreates, the copy of the private variables is destroyed as well, since these are limited to the specific instance of the variable instead of being used by multiple blueprints.

Pardon me with this, but I’m trying to get my understanding correct on this.

Why would this be different if the variable isn’t an array. Wouldn’t other types of variable be destroyed when moved ( if it’s meant to be destroyed )

Hi ,

You are correct, if the variable is private, even outside of an array, it will be destroyed with the actor then recreated. I was able to replicate that effect by setting an int variable from 0 to 1 at begin play, then print string on tick of the variable. When this occurred, as soon as I moved the blueprint it reverted back to 0.

Just tested this…it seems to be correct on what you’re saying. My initial test on non-array was incorrect.