Strange SetActorLocation behaviour
I'm getting some weird results when using SetActorLocation to reset the position of a floor tile in an endless runner project.
I have the tiles moving towards the player and when they get a certain distance behind the pawn they are moved to the rear of the tiles and reused.
The strange thing is that the first tile (and only the first tile) which is reused always has a slight offset from where it should be, leaving a small gap between the tiles. All other tiles after that are fine and snap perfectly to the tile next to it. The code is really simple, it gets the world position of the far edge of the current rear tile, and passes this into the SetActorLocation of the current tile about to be moved.
Another thing that I found interesting but can't quite see why it works differently is that if I don't reuse the tiles but simply destroy the out of bounds tile and spawn a new tile at the rear using the exact same logic to get the position, this also aligns perfectly with the tile next to it.
This makes me think the logic of getting the position is fine, but something weird is happening with SetActorLocation in this really specific situation on the first tile being moved to the rear of the queue.
Any insight here would be amazing as this is driving me crazy. I know I can just use the SpawnActor function and bypass the issue, but it seems like it should work either way...
Function to get the location of the edge of the rear tile:
Function to move tile:
Gap in tiles after first tile has been moved to the rear:
Follow this question
Once you sign in you will be able to subscribe for any updates here