Hi there in my save system Im trying to make a simple save/load system for objects that can be placed. In these objects I am saving the actor transform using AActor::GetTransform and saving the class
All works fine except after several saves and loads they start hovering in air a little more with each save and load which is incredibly odd. These are not special actors by any means, they’re glorified props the player can spawn in by clicking where they want to add the actor (IE they spawn under the mouse on click)
Its SO weird. In both of my spawning methods - the initial creation and the loading functions - I set the spawn collision handling to Always spawn and while this helped initially
this might be a result of “Floating Point Approximation” the reason why sometimes a number you set to zero in the transform might suddenly be -.0000000001 or a rotator at 90 might suddenly become 89.9999997 because of the ways Floating point number work (yes I know they are of type double but that is talking about the range of values not the precision of values)
are these objects supposed to be staticMesh like things or are they supposed to have physics.
if these are supposed to be static then you might need to create a Structure to effectively “re-Place” them into the world on Load (this might mean slightly longer load times, but more consistency) where you traverse the structure effectively replacing the objects, and then stepping through all the objects and inserting values for instancing.
have the structure be constructed based on Z above ground then as you put them into the world shoot a ray/sphere in the direction of negative-Z and if the value of the distance is greater then a tolerance move it down by the difference)
That fixed it - although since the actors that are being loaded were already using a struct I just added a transform variable within the actor and when I initialize the actor from my load method, instead of saving the transform each time I simply just grab the original saved value and make sure its passed down through “save generations” by setting the transform variable on the actor to the saved one when I call my load method