top of page
Writer's picturebloghoarder.com

Unreal Engine Tutorial - How To: Create multiple starting locations in the same level


Hi everyone, in this tutorial, we will be creating different locations to begin a level from. This way when the character enters the level they'll begin play at one of the multiple locations that we choose.

 


 

PT 1 Game Mode (for the level with multiple Starting points)

Either set the Default Pawn in the Game Mode to None or

have None selected in the Game Mode Override in the level's World Settings.


PT 2 Spawn Location Actors

We will create actors to place into the level and represent the different locations that are character will begin play from.

In the content browser

Create Actor Blueprint.


In the Actor Blueprint (BP_SpawnLoc1)

Add an Arrow component.

Set the arrow to Hidden In Game, in the Details under Render.

In the content browser

Duplicate actor for each spawn location in the level (BP_SpawnLocation2,3,4...)

 

PT 3 Game Instance

Next is the Game Instance where we will hold variables representing the spawn points.

In the content browser

Create a Game Instance.

In the Game Instance

Create a Boolean Variable for each Spawn Location.

In Project Settings

(Edit, Project Settings)

Set the Game Instance.



 

PT 4 Level

In the Level with multiple spawn points.
  • Place the Character pawn into the game level from the content browser.


  • Place the Spawn Location actors into the level at the locations you will be spawning from.

  • Rotate the Spawn Location actor to point the arrow in the direction you want your character to face when spawned into the level.

In the Level blueprint

From Event Begin Play, (as a preference but not necessary, I'm first going to Get Player Controller, then Set Input Mode Game Only, and Set Show Mouse Cursor to False. Again this is preference and may not work for you in which case, simply ignore.)


  • Then (or right off of Event Begin Play based on your game) cast to the created Game Instance and Get Game Instance as the object reference.


  • Get the Spawn Location Variables from the Game Instance cast.

  • From the Game Instance cast to a Branch with the first Game Instance Variable for the first spawn point.

  • Cast to another Branch from the first Spawn Branch's Fail.

  • Add the second Spawn Location Variable as the Branch Condition.

Continue adding Branches with a Spawn Variable as the Condition for each Spawn point in the level.


  • Drag the Level Blueprint Tab down towards the centre of your screen so it is minimized as its own window.


With Level Open
  • Select World Outliner.

  • Inside the World Outliner, select and drag the character into the minimized Level Blueprint to create a reference to the character.


  • Also, select and drag the Spawn Location Actors from the World Outliner to create references to them.

In the Level Blueprint
  • Drag off the Character Reference and select Set Actor Location And Rotation.

Do this once for every Spawn Location Actor in the level.


  • Connect a Set Actor Location And Rotation to each Branch's True executions.


  • Connect the player reference to the Target of each Set Actor Location And Rotation node.

  • Drag off the first Spawn Location Actor reference and Get Arrow.

  • Drag off the Arrow and Get Socket Location. Drag off the Return Value and connect it to the Location Input on the Set Actor Location And Rotation node that it corresponds to.


  • Drag off the Arrow again and Get Socket Rotation. Drag off the Return Value and connect it to the Rotation Input on the Set Actor Location And Rotation node.


  • Right-click in the blueprint to Get Player Controller.

  • From the Player Controller, type Posses, for the node.


  • Connect all of the Set Actor Location And Rotation to the Posses node.


 

PT 5 Set Active Spawn Point

To begin the level from a chosen spawn point one of the Level's Spawn Point Variables needs to be true and the others false.


I'll create a few box collision actors to trigger the Level Transitions inside a few separate Levels that connect to the main level.

In the Content Browser
  • Create an Actor Blueprint BP_LVLtransition1.

In the Content Browser
  • Inside Actor Blueprint BP_LVLtransition1, add a Box Collision component and compile the blueprint.


  • Click On Component Begin Overlap, cast to the character and connect the Object Reference to the Other Actor pin from the Begin Overlap.


  • From the Character, cast to your Game Instance and Get a Game Instance for the Object Reference.


  • From your Game Instance object reference set each Spawn Variable for that level with the Spawn you want used as True and the others as False.



Pulling off the last set variable is the level transition code to get back to the main level with the multiple Spawn Locations. My example for level transition will include a loading screen.

 

PT 6 Level Transition

In the Content Browser

  • Right-click, User Interface, Widget Blueprint to create a loading screen widget, (WBP_LoadingScreen.)


In the Loading Screen Widget Blueprint
  • Drag an Image from the Palette onto the Canvas Panel and cover the screen. With the image selected input 1920 for Size X under the Slot section of the Details Tab and 1080 for Size Y. Anchor it to the full page.


  • Change the colour to black in the Details Tab under Appearance then Color and Opacity.


  • Drag Text over the Canvas Panel and type Loading in the Content Text in the Details tab.

Back in the Transition Collision Blueprint
  • Drag off the last variable to get Create Widget.


  • Select the loading screen widget and select the Loading Screen Widget in the Class input.


  • Drag off the Create Widget node's Return Value and Add To Viewport connecting their exec.


  • Connect the Add To Viewport node to a Delay and leave the time at .2.


  • Connect the delay to Open Level By Name and copy the level name into the node.


  • Drag your Transition Collison actor into the level you are transitioning from.


 

PT7 Final Touch


  • To finish up this tutorial and properly demonstrate what we've done I will create 3 last transition collisions to place in the main level out to the levels we are entering from.

  • After I drop this last transition into the main level there is only one final thing to do.

  • The very last thing is to set a default spawn point to be true in the game instance.


 

Thank you very much for checking out this tutorial.

Until next time,

Game well and prosper.



134 views0 comments

Recent Posts

See All

Comentários


bottom of page