How would I spawn the player at a specific point when opening a new level?
I'm making a 2D top down game similar to The Legend of Zelda: A Link to the Past
I have a level named "Town" that acts as a level hub. When the player walks into a house or shop, they are teleported to a new level containing the insides of the house or shop. The problem starts here, when the player walks back outside they will always spawn at the initial player spawn point. I want the player to spawn outside of the door they just walked out of.
How would I set a specific spawn point so my player can seamlessly exit buildings and end up where they should be?
asked Apr 26 '18 at 07:34 PM in Using UE4
The GameMode class has a ChoosePlayerStart function, that you can override in its blueprint/C++ class. I'd say, you keep an integer ("StartIndex" for instance) with the index of the PlayerStart you want to choose, in a GameInstance class. Then, when the player goes through the door, you change the index, from 0 to 1. In the overriden function, you get all actors of class PlayerStart, and return the one at the index you saved in the GameInstance class, and that way, you get different starts depending on where you exited another level.
If you didn't understand anything i said or need a hand let me know.
answered Apr 26 '18 at 07:50 PM
Thank you for your help, unfortunately I'm still a little lost. I'm very new to unreal so I get lost pretty easily. This is what I have at the moment.
I made a GameMode BP, but I couldn't find the "ChosePlayerStart" function. Is it called something else or have I done something wrong?
answered Apr 26 '18 at 09:36 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here