I have an actor that I’ve set the transform of in a function. Everything works great until I get down the execution line to a function call for a function in a separate actor’s blueprint. Somewhere between calling the function and executing the function, the transform of the actor I just set shifts by a couple units. This is incredibly annoying since I’m trying to set it to a very specific location that if shifted by a couple units makes it look strange. It’s not consistent either. Every time I try to debug the actor shifts differently and randomly.
I’ve used print string nodes to narrow down the problem to this specific function call, but I just don’t know what to do about it. I appreciate anyone who takes the time to help me with this.
Where the function is called:
@Shunitzo No the ghost coin is on the money. And that’s how I set the coins transform is with the ghost coin. I’ll save you the spaghetti I’ve made while trying to debug but here’s the output log where the coin’s transform is set correctly before shifting a little bit where I mentioned before.
First, you really shouldn’t make sutff that requires that kind of precision (in an engine that’s nowhere near scientific, since the value will fluctuate).
Second, you coud try to world origin shift the item/scene to 0,0,0 to work around it…
That way you have the widest chance of not having to rewrite the whole thing.
Third, would it not be easier to fake this with precomputed math/calcs?
Bonus/4th…
Are you sure that the coin isnt also simulating physics?
@MakeHost_LA I’m new to UE5 by like a month and this is my first real project so a lot of what you just said makes no sense to me lmao.
First, after googling floating point precision, in this situation, I don’t understand how as the engine processes this function call after correctly assigning a new transform to the coin that was directly copied from an already correctly assigned transform of the ghost coin that the X and Y values would be rounded to a value +/- a full unit or more from what it’s supposed to be. Like in the first output log I posted, the Y was supposed to be 541.764 but then changes to 540.161. That seems like a crazy amount of shift for a floating point precision problem. I get the engines not scientific but that seems a bit much.
Second, I don’t understand what you mean by “world origin shift”, google didn’t have much to say about that. The way I have it written, it shouldn’t matter where the coins and the scale are in the world because I use the grid itself to tell the ghost coin where the coins can be placed.
Third, i tried precomputing where the coin is supposed to go and hardcoding it in but I have 18 grid spaces on a scale that has 3 different positions for all 18 of those grids and the coins are meant to be stacked on top of each other up to 5 times for another layer of “where should this coin go after left click is released” and it still wouldn’t work properly after a full day of tweaking. The problem isn’t that the coin is going to the wrong place because of wrong input which is what’s making this so frustrating.
Fourth, I’m like 99% sure because the coins aren’t affected by gravity or collisions in the simulations and I never enabled physics but idk where to check if they are or aren’t.
Kind of. But the amount depends on how the engine is storing/setting that value in the forst place.
Normally, at above 500 units from center you cant rely on .001 already.
Well, instead of doing that, fake it. Change the mesh of one coin to be the mesh of all coin joined together.
The grid thing could also be throwing off placements.
Your coin can also be the issue. Make it precisely a single unreal unit (thats 1cm not 1m).
Scale up or down your scale to match the coin.
With the coin being precise and the scale plate being precise, you can likely place the coin at integer values and avoid most precision issues…
@Shunitzo The grid is a series of Planes with see through materials that I’ve slightly overlapped to make the grid lines. Each coin actor has a vector array variable that stores the positions of all of these planes plus a little offset in the Z axis. The scale actor takes all of the coins in the scene and updates that array with the current position for each of the planes after it moves when the weight shifts. The coins also have an int variable that acts as the index for which square in the grid that it’s been placed in, -1 being the default to show that the coin hasn’t been placed yet. When a coin is held by the player and the left mouse button is released, a ReleaseCoin function is called on the coin actor and I’ve got the entire execution line below. After the coin has “supposedly” been moved to where the ghost coin was, all of the coins in the scene that don’t have a -1 in that index variable are parented to the scale plates that they’re placed on so that they move with the scale after the weight changes.
I appreciate everyone’s time in trying to help me. Sadly none of the suggestions really fixed the problem and I still have no idea what the problem ever was. I did find a work around though and feel like a complete numbskull for not trying it earlier . I just moved the set world location nodes for the coin and ghost coin to execute after the problematic function call for Update Scores and Scale. Still don’t know why that function call was causing so much pain and agony for me but just reorganizing the execution did the trick. Thanks again, @MostHost_LA and @Shunitzo for your time!