5
\$\begingroup\$

I'm trying to make a game in Unreal Engine 4.8,

I've got a Player Start actor in the main level and a box collision that loads a new level, but when you return to the main level you obviously spawn at the Player Start, how can I make the player spawn at a specific location on the map, because I've tried with a lot of things and they didn't work. enter image description here

For example I start at the tent and you walk to the house, you enter the house level, and after a few minutes you leave, what happens is that you spawn at the Player Star and I want to spawn in front of the house.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

There are lots of ways to do this kind of management for reloading a level after a transition.

One way that comes to mind is the use a global object that persists between levels during level transitions. This object could be something like a UGameInstance that tracks the position in the last level that the player was at before transitioning to the new level. When the player leaves the house level, in the "overworld" level, you check the UGameInstance for the player's last position and set the location to there. The player won't notice a thing because it will happen in the same frame.

Another way is to implement a custom level spawn manager for your "overworld" that has several IDs pertaining to the index of a PlayerStart in the level that you have placed. Then you can associate an ID when you leave a certain level (like the tent or house) and pass it as an option when you load the level. You will then set the player's start to that PlayerStart instead of the default.

Finally, you can use the save/load features of the engine when you transition through levels.

Here are several links you can use for reference:

Finally, take a look at the ShooterGame as it has code to choose spawn points. It is overkill for this, but lets you read code and get an idea of how to implement an spawn chooser class that you would just tweak to use in code based on the level you just left.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .