Announcement

Collapse
No announcement yet.

Return to same spot from level

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Return to same spot from level

    I'm sure this has come up before so I've searched the forum but no joy, sooooo: Fairly new to Unreal & blueprints. I've created a second level my player "goes to" after unlocking a door using the event OpenLevel from the first level. This is kinda a sub-level of the first level. Returning works fine using OpenLevel again but it takes to player to the initial player start position on the first level - as you would expect. I want the player to return to the point that he left the first level from so that he/she can complete that level before progressing further in the game.

    I suspect I need a global variable to tell the first level which player start point to use when it loads but that's about the extent of my knowledge so please keep any help simple!!

    Thanks in advance

    Ray

    #2
    You can place a trigger in front of the door. If the Player goes through the trigger, takes this Location and set it up in a variable in your gameinstance. Then if you came back, check over a bool (in gameinstance too) if the game was started or it is running and set your Players Location to the saved Location.

    The Gameinstance is not being destroyed if you load a new Level. All variables in it will live forever until you quit the whole game.
    01010100 01101000 01100101 00100000 01110100 01110010 01110101 01110100 01101000 00100000 01101001 01110011 00100000 01101111 01110101 01110100 00100000 01110100 01101000 01100101 01110010 01100101 00101110 00100000 01010100 01110010 01110101 01110011 01110100 00100000 01101110 01101111 00110001 00100001 00100000

    Comment


      #3
      I agree with Beregron. The Game Instance isn't destroyed when you're opening different levels so it's your best bet for saving information across level transitions. You can create a new blueprint for one and set it as the default Game instance to use in the project settings. Create a new vector variable in your Game instance blueprint, and when you need to save your pawn's location, use the node "get game instance". Cast from that to your custom Game Instance Blueprint and you'll be able to get and set the vector that you created in there.

      Comment


        #4
        Originally posted by Beregron View Post
        You can place a trigger in front of the door. If the Player goes through the trigger, takes this Location and set it up in a variable in your gameinstance. Then if you came back, check over a bool (in gameinstance too) if the game was started or it is running and set your Players Location to the saved Location.

        The Gameinstance is not being destroyed if you load a new Level. All variables in it will live forever until you quit the whole game.
        I think I understand what you're saying but I don't know how to set the location for the player to reappear at. Remember I'm practically an Unreal virgin :-)

        Comment


          #5
          I've sorted this by starting by asking the right question. "How do I place the player at a specific spot when I start a level". I've created a persistent variable in my game instance blueprint and simply check the value with the BeginPlay event. Based on the condition of my variable I just teleport the player seamlessly to the desired position. No need to move the player start at all.

          Thanks for your help anyway!

          Comment

          Working...
          X