How to Open Level and Set Player Position?
I'm working on a 2D sidescroller with different levels. I have created a save game system which allows me to save the position of the player and what level he is on.
When you load the game, the saved last level opens and the player is teleported to the saved location. It should be so.
Unfortunately, the player always starts at the Player Start object. If I do not open the level and only teleport the player, it works. But only if I start from this level.
Sorry for my bad English. I am happy if someone can help me. :)
asked Feb 11 '19 at 12:56 PM in Blueprint Scripting
There are 2 issues with your game calling Teleport event. First, when you load a level, your Pawn isn't created yet. Second you are calling Teleport before GameMode's InitStartSpot occurs which is responsible for choosing where PlayerStart and spawning your Pawn in its location.
Try moving your call to Teleport event during GameMode's BeginPlay. That way, you're sure that your Pawn is already created and spawned before teleporting him where he should be. You probably want to call Teleport when you know you loaded a level, so you may need some extra variables to take care of that.
answered Feb 11 '19 at 01:53 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here