Restart an endless runner game

I have built an endless runner based on epic’s endless runner tutorial series : Endless Runner: Overview & Player Control | 01 | v4.7 Tutorial Series | Unreal Engine - YouTube

I could either use a change from maps to make the game restart or use the “RestartLevel” Command that Blueprint has, except both of them make my app crash.

Therefore, I need to create a restart level system.

My thoughts on this were:

1 - Teleport the pawn to a box while the track is being respawned.

2 - Destroy all the spawned course should the player be dead (This is run in the tick inside the track’s blueprint)

3 - Clear the course’s array by casting it on the level blueprint.

4 - Because each new part of the course needs a transform value so it spawns correctly in front of the previous one, I have a target point at the end of each part which is where the transform gets the value from.

5 - Considering I need to reset this transform as well, I have set it’s location the same as a targetpoint I have in the 0,0,0 axis in the world.

6- Spawn a new course

7 - Teleport the player back to the course at the start when all the tiles are spawned

After implementing all this, what happened was:

1 - Character moves on, dies and sometimes either stays on the small box that is where it is meant to wait, but never leaves it

2 - If I die close to the start of the game, my character is teleported correctly to the target point at the start, however if the character has moved for a while in the game, it will no longer be teleported back to the exact location as the target point, which it should, as the target point never leaves its position.

If needed, I will post my blueprints here, but if anyone has a suggestion on what I should do to fully restart the game in blueprints in a easier way. Please let me know.

Thanks in advance! :smiley:

I discovered this later on, you need to get all actors of the tile class you have, destroy them, then you set the value of the transform of the last tile that keeps track of where to spawn the next tile as 0,0,0 so that when you respawn your player the track respawns in the exact same place.

Also you need to destroy your actor and possess him again when you restart your game. Any questions regarding this let me know, I will try to help you :smiley: