So, as with many RPGs, levels have many spawning points.
Let’s assume there’s a level where you start in the center, but you can go through passages on the left or to the right. If from either passage you walk back into the room, instead of respawning in the center, how can I have the player respawn in the level next to the way they exited, rather than the level’s spawn?
Here’s an example:
Let’s assume this is Level 0. If the player walks up to the Left Exit, they’ll enter Level 1, but if FROM Level 1, they enter the right exit, then they’ll enter Level 0 again, but next to the Left Exit, not the center of the level, where’d they’d spawn by default.
If anyone could help that’d be great.
Have a nice day
If you create your own GameModeBase, you can override its ChoosePlayerStart or FindPlayerStart functions and use GetAllActors to loop through all PlayerStarts in the level and pick the one you wish to spawn at.
Thank you! I’ll be sure to report back here if I have any other questions.
personally i would have a system where when you get to the level exit then you save a variable to the game instance which would be used to decide the location to spawn the player when the next level opens. so basically in your picture when you move to the right edge you would have a script that sets a variable (spawnLocation) in the game instance (for example have it set to the value right or left), then opens level 2. then when level 2 opens you immediately set the characters location based on the variable in the game instance, in this case it would be set to left, so you would have a predetermined vector or marker such as a target point, and you would set the characters location.