Announcement

Collapse
No announcement yet.

Get current level name

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

    Get current level name

    How can I find what level is currently being played in Blueprint?

    I'm not using streaming levels and can't find any other mention of getting level names.

    #2
    Hi Epok,

    I was trying to figure that out as well. Unfortunately I haven't figured it out yet so I came up with another solution for my project which works for me for now. Create an Enum and add the names of all your saved levels. Now in level blueprint you can create a variable and choose enum as type. Under that list you should be able to find the title of the enum file in your content browser show up. Now you should be able to choose any level you want to go to next.


    Click image for larger version

Name:	levels.jpg
Views:	1
Size:	169.7 KB
ID:	1051008
    Nodes used.
    Enum -> to string -> to name -> open level
    Isaac Nichols
    Game Developer & Music Producer - Threaded Pixel Studios
    Currently working on Drones & Ruins a Sci-Fi twin-stick shooter.

    Comment


      #3
      Thanks for the tip!

      Unfortunately this isn't suitable for what I'm trying to do as I need my game to know what level it is on when it has been booted from a random level in the editor.

      Comment


        #4
        Whenever it chooses the Random Level you should be able to save the name of that level in a variable.
        Map Generator 1.0
        Map Generator 2.0
        Map Generator 3.0

        Comment


          #5
          The random level isn't chosen by any code/blueprint though, it's just whatever level is loaded in the editor when you hit play. I need a way to find out what that level is, so it can be stored as the current level.

          For now I've 'hard coded' it into each level's Level Blueprint, but doing that on every new level would suck! There must be a way to automatically detect it.

          Comment


            #6
            Is a bit of a hack but this works, just be careful to avoid underscores (_) in your level name.

            Click image for larger version

Name:	hack.png
Views:	1
Size:	75.2 KB
ID:	1051153

            Comment


              #7
              To clarify some confusion - it works in Level Blueprint, although "Get Display Name" doesn't appear in context menu or even out of context menu in Level Blueprint.
              I've just recreated the nodes in other blueprint and pasted to level Blueprint.

              Comment


                #8
                I don't know if this will help, or even if it is what you are looking for, but what we do is:

                >Create an actor called LEVEL_SETTINGS.
                >Create a public variable string called MapName.
                >Create whatever other variables we need.
                >Drop an instance of it into the level.
                >Set the map name.
                >Then from whatever blueprint/code you want to check the level name from, just ForEach->GetActorsofClass(LEVEL_SETTINGS)->Cast to LEVEL_SETTINGS->Get MapName.

                This works for us, since we need that map name.

                Comment

                Working...
                X