(Since 1.1)
To tarvel from one level to another (or from one gate to another in the same level), the Player uses the Travelling system.
This system is composed of 4 parts :
1) BP_LevelGate and BP_SaveSpot are the actors the Player will be teleported to when he travels :
2) You need to place the BP_GameModeTravelerComponent inside your game mode. In addition, you need to modify the EventHandleStartingNewPlayer() as following in you GameMode :
3) You need to place the BP_TravelComponent inside your Player. It's better to put it directly inside the PLayerController and not the Pawn.
Make sure to init this component when the game begins :
When the game begins you can load the player like that :
4) You need to make your player implement the BPI_Traveler interface. It's better to put it inside the PlayerController and not the Pawn.
Then you'll need to implement this interface by overriding those functions :
- GetTravelComponent : Simply return a reference to the TravelComponent.
- GetPlayerController : Simply return a reference to the PlayerController.
- LoadDatasAfterTravel : This function is called after the player as travel to another level. Implement it so that the player loads it's previous datas from before the traveling.
- SaveDatasBeforeTravel : This function is called just before the player travel to another level. Implement it so that the player save it's current datas so that he can retrieve them after the travel by using the LoadDatasAfterTravel.
- SetPawnEndTravelLocation : Interface to place the pawn in the level using a position/rotation. Sometime you want to perform additional actions here, like stop the movement of the pawn.
- SaveLocally : Implement it to save the player's datas locally. This function is used to save the player's data before you travel to the MainMenu.
- Respawn : Implement it like you want to give the player a way to respawn.