Mesh overlap in endless runner

Hi guys,

I’m trying to make an endless scroller template and have trouble placing the meshes correctly. They overlap and I cannot figure out why.

The mesh I’m using is 800x2400x0 and the level scrolls along the y-axis.

I use this simple script to move the mesh 15px per frame:

And this script to place a new instance of the mesh (not so) immediately after (in lack of better words) the previous one.
There are two box components in the blueprint that function as “spawn actor” and “destroy actor” activated on onBeginOverlap.

Looks like this:

If I change the y-value to 2415 instead of 2400, the meshes line up perfectly, but It seems like a hack to do it that way and it also causes some issues for me when incrementing the speed.

It seem like such a simple thing to do, so I imagine I must be starring blind at something, and have done so quite a while.

Does anyone have a clue as to why this is happening?

Thanks.

/Kenneth

I can imagine that it takes one tick to move and spawn the actor. So if you spawn a new one, the old one moves 15 units in the same time.

This would explain why you need to add 15 units to the location. Doesn’t seem that hacky to me.

You could just add the speed variable to 2400, so you will always have the right amount of units added.

Yes, I agree about the tick. The issue that arises (possibly for other reasons) is that the newly spawned mesh moves slower than the previous one when incrementing speed, which then creates a bigger and bigger gap.