Using member variable `std::variant<...>` creates a mess

So C++ supports some neat features that I know and value from elsewhere. E.g. std::variant<int, float> Foo allows a variable that either contains an int or a float. You can then later make a case distinctions using

std:visit(overloaded
{
    [](int&) { /* do somehting */ }
    [](float&) { /* do another thing */}
}, Foo);

In my case, I have Kepler orbits (of asteroids) that are either circles, ellipses, parabolas or hyperbolas and instead of int and float I put structs into my variant because different Kelper orbits have different parameters associated with them.

using Orbit = std::variant<FCircle, FEllipse, FParabola, FHyperbola>

Using the visit pattern, I properly deal with setting up the Spline and such.

If only it worked.

Somewhere between my OnConstruction and Tick, the member variable Orbit MyOrbit gets set to an uninitialized Circle struct.

I know that for sure because my OnConstruction function updates orbit information that is visible in the editor. Only once I start the simulation, the orbit information apparently is reset to some uninitialized state.

I would guess, the reason is that MyOrbit is not a UPROPERTY and I can’t make it one, because the type std:variant<...> is not supported for UPROPERTYs.

However, this is just a guess. I don’t know if there is such a reset.

Also, luckily when launching as standalone game, everything is fine. This confirms my suspicion that this behavior really is some bug.

As a workaround, I could move my Orbit initialization from OnConstruction to BeginPlay, maybe.