Teleport objects to new world origin location?

Hey, I’m making an endless runner game and I noticed that if you move the character instead of the floor itself, you eventually run into the world bounds. So, thanks to a bit of help from a similar question someone asked here once before, the world origin is able to be reset just fine to keep the game going endlessly, but I can’t seem to teleport any of the objects beyond the few already spawned (and the player character) to the new origin location. The floor tiles just keep spawning from the same location before the world origin reset as if it never moved, leaving a huge gap between the character and the next set of floor tiles. Is there any way to bring those floor tiles to the new world origin and keep spawning from there? I have a few screenshots of my current setup (I’ve tried this a few different ways in various blueprints already, so far always with the same result). The first image is the floor spawn code in the game mode, second is resetting the origin after a certain time has passed (for testing purposes right now) and then (attempting) teleporting objects to it (also in the game mode currently), and the third is the set world origin function, stored inside the pawn, so it could be accessed easily. Thanks in advance for the help!

I think you want to set the origin to the ball location, but it looks like you’re setting it to it’s current location plus the ball location… and you’re setting the variable ‘location’ to the same value as it’s already at ( just noticing things here ).

Hey, could you elaborate a little? I can’t seem to find where that might be happening. Attaching a Print String node to get the world location shows it resets at the ball’s location on the x-axis, but I don’t see where it’s being set to it’s current location as well?

Your orange ‘location’ ( transform variable ), it always has the same value. Yes, you are resetting it, but to the same location you just spawned to.

You also have something on tick, but nothing happens for 15 seconds, then it only happens once…

( will come up with something more useful in a moment probably… )

( to your question about location - you’re doing an addition in the set origin calculations, you’re adding where the ball is + where the location already is )

Yeah, there’s one Master floor tile with all of the other variations as child blueprints, which are stored in an array for the spawns.
I can move it easily if need be. Just copy and paste the code over to the level BP.

That’s why the floor tiles are always spawning at the same location, because you’re not changing the location :slight_smile:

Edit: Sorry, my bad, you’re updating the spawn location with the spawn point on the ground mesh…

Are the floor tiles BPs? You either need the code to move the floor tiles in the tile BP or you need to have a foreach on an array of tiles in the main BP.

Incidentally, level BP is the place for this code, not really the game instance.

I will get something similar working and get back to you…

No worries! I thought that might have been what you were referring to, but I wasn’t sure. Having said that, that definitely does seem to be part of the problem, since the tiles keep spawning from the last location of the floor spawn points before the origin resets, instead of the tile spawn points at the new origin completely. I wonder if it’s being caused by the fact that the floor spawns are on a loop, so even when the origin is reset, there’s already spawns in place and thus won’t have any more until those triggers are passed? I would still need to teleport the new tiles then, which I’m positive I’m not doing correctly right now lol

So, I have a piece of floor with a collision box on one side. When the player reaches the box, it spawns a new piece in the adjacent area. Not exactly how you’re doing it, but similar concept:

And in the level BP, I’m moving the origin once a second. Tick is too much for something you don’t actually see.

I was right about the addition being incorrect. If you use that code, within about twenty steps, the origin is virtually at infinity! :slight_smile: ( because it’s constantly summing it’s location ).

I hope this stuff is of some use…

The floor gradually getting further away does sound a bit like you’ve got the spawn point in slightly the wrong place… ( Not sure what you have going on with the spawn there, as I’ve used this method for indefinite size mazes etc, so I know it’s fine :wink: )

I gave it a try, both on a new project (just using the Third Person content) and my current one. It works perfectly on the new project (though I haven’t tried looping the floor yet to spawn several at once to keep the camera view filled). But, when I try it on mine (I’ve tried it with both your floor spawn method and my current one), some issues start to pop up. Using your floor spawn method, the in-editor game crashes after passing through the first couple of collision boxes and causes the scoring system to go haywire, resulting in a “Stack” error. With my spawn method, there’s no error, but there’s always a gap between the floor pieces, and the gap gets progressively wider on every new floor spawn. I’m really unsure as to what’s happening here, since your code works great on the separate project. I’m going to try copying my spawn method over to the new test project in a little bit to try it out, and see if it might just be UE4 causing issues on my current project (it wouldn’t be the first time I’ve had that happen lol). I’ll post back here with an update when I try it out. Thanks for all of the help so far! :slight_smile:

I thought so too, so I tried moving it around, but it always separates after passing through a few of the collision boxes. The spawns work fine without moving the world origin, moves when it is reset, and yet your origin code works great on a brand new project. What’s going on UE4 xD

It is strange. I experience absolutely nothing when I move the origin… ( I mean no discernible effect ).

So, I have your spawn method working for the most part (the spawn point didn’t want to work correctly with mine when resetting the world origin), and a new scoring system in place, as the old one was going nuts for some reason, and the world origin resets fine, but I haven’t been able to fix the Stack error that keeps showing up as a result of the new floor spawn (even though I’m sure that’s not the problem). After about 10-20 floor tiles have spawned (even with deleting the old ones), the game suddenly gets really laggy and freezes, then the game crashes and gives me the Stack error (which doesn’t happen on the test project I made). If I increase the player movement speed (which I’m doing for added difficulty in the game), the crash happens sooner. As far as I know, the code is identical in both my current and the test project, which leads me to think I should probably try migrating all of the project contents to a new project and try from there. Maybe something got corrupted at some point?

The origin reset works great though, which was the main problem for this question, so thanks for helping me get that sorted out! I really appreciate it! :slight_smile: