How can I use a portal to travel to specific locations in the new level?

Hello, I made a portal (from a tutorial) and it’s working fine:

I want to travel between different rooms like in Resident Evil 1. But for that I need a function for the location in the new level. How can I add the location to my blueprint?

Here’s a first attempt. But it doesn’t work because I don’t know what I’m doing :slight_smile:

Bin ich auf dem richtigen Weg?

There are actually several ways to do it.

One way is to safely store the location in GameInstance, which persists between levels.

Another way is to pass the location through the options in “Open Level …”. For example:

and then, for example, read it at the gamemode and place the character at the right location:

You can also override the “Choose player start” in the game mode.

PS: note that I used “TargetPoint” as an example to get a location and it works because I’m opening the same map I’m already in. In your case, you will probably get the location using some other mean. For example, passing a tag or name of some actor present in the next level (or a hard coded location).

Hello and thanks, that looks very promising to me. But I don’t fully understand it.

  1. Are the two images two different solutions? I inserted a TriggerVolume into my first map and then created the same as your first image into the LevelBlueprint of the firt Level/Map. Then I tried to understand what you said about the TargetPoint. I don’t understand what to use instead of the TargetPoint. I tried using different meshes and blueprint actors but nothing works. My character starts at the player start or in another location (when deleting the player start).

  2. The 2nd picture I also tried to build in my gamemode. I connected it to EventBeginPlay. But I don’t know how to create the node between SetActorLoc and ParseOption. Maybe 2nd picture is for the tag-system?

  3. AND: In my gamemmode there is no “Spawn Default Pawn at Transform”

You can not do anything after you execute open level. Because new level loads and this blueprint is no longer there.
If you want to set your characters location in a new level, you have to do that it in the level you opened.

Hello, yes… that’s what I suspected.

Here I show my current attempt. I think you can tell I’m guessing. First I created a Boolean in the Blueprint Actor after overlapping a CollisionBox:

Then in the OpenLevelBlueprint after EventBeginPlay I tried to determine a location when the Boolean is ON:

But it’s not working. It was just another attempt.

I absolutely don’t know how to reach my goal. The pictures from user EvilCleric look competent, but I can’t implement it.

  1. Make game instance
    2.make that game instance your projects game instance(in project settings - project - maps and modes).
    3.in that game instance make variable “character_location”(vector type).
  2. In portal blueprint before you open new level - set character_location variable (you will need to refrence the game instance with “get game instance” and cast to your created game instance), then execute 0.3 delay and than execute open level.
  3. in the level blueprints (that you are teleporting) on event beginplay - refrence to your character_location variable (from game instance) and set your characters location in that level.

There are other ways as mentioned, but this is the simplest.

The 2 images are for the same solution. Never mind the trigger. What’s important is the options that you add to your “open level”. The options consist of string made of keys and values: “key=value”.
So, you can pass whatever you want: a location, a tag, a name, …
In the example above, I simple passed a location of an actor in my current level, but you can hard code a location directly.

As for the node between parse options and set actor loc, you just need to take a wire from parse options and chose “convert string to vector” (i didn’t use the output boolean but you should, since it indicates that the conversion was sucesseful).

As for the “Choose player start”, is better to forget that for now.

Note that the easiest way is to use game instance (or whatever system you’re using to keep data between levels, like score and health) instead of the options. Game instance is a global object that is acessible everywhere.

At first I want to show my screenshots from the description from user Dejan33.

At the moment it’s not working, because I make something wrong.

Character_Location_Variable in the GameInstance:

Set Variable in the Portal Blueprint (Portal_X):


(Level name is correct. I changed it from “demonstration_3” to “destination_level”)

And here is the Level Blueprint from the “destination_level”:

But it’s not working. Character is not even changing level but teleporting to an unspicific location in the start level. Don’t know what I am doing wrong.

It should teleport you to location 0,0,0 in the destination level.
If the new level (destination level)doesn’t open, try removing the delay.
Also you have demonstration level and destination level. Which is it?
You are opening demonstration level instead of destination level.

Okay, it was 0,0,0 where I teleported to. Didn’t realize I can change the value there because details were grayed out. This is working now, but not not the level-switching.

I tried it with deleting the delay. Also I placed the loc_variable behind open level. Both make no difference.

(I changed the name of the level. I added a sentence below the screenshot after you already read it. )

At the moment it is not working already yet.

Ok, make sure the level name is exactly as the level you want to open. Never execute anything after open level(as mentioned before).
Try opening the level without anything between. Just overlap and open level.

Okay, but then I don’t understand that I have to put “SET Character_Location” before “Open Level”. Is it correct that it must be there?

Yes. Nothing executes after open level. You can set location wherever(whenever) you want, but not after open level.

Okay.

And here are the screenshots of the other variant of EvilCleric.

Set Actor Location in the game mode:

And opening the level in the level blueprint:

Am I on the right way?

The funny thing is: Changing levels doesn’t work with either version.

i think there is a lot of confusion here.
Let’s go by parts.

  1. Each room is a level?
  2. You are in level X and you enter a portal that is going to take you to level Y. Right?
  3. Are there many portals in X and does each portal takes you to a different location in Y, or does each portal takes you a completly different level?

I think if you explain a little better the relation between the portals, levels and spawn points would be nice.

  1. Yes, each room is a level. The rooms are not very big.
  2. Yes, exactly. The portals are doors. Like in Resident Evil 1. If player walks through one door in level X then he must come out in front of the correct door in level Y.
  3. I assume the game will have approximately 20 main rooms. You go from room to room. Every room has at least 2 doors. Entry and Exit. Player can go forward or backwards in the game every time. From time to time there are up to 4 doors per room, because here and there you have some tasks and you must find a way. But all in all it’s a straight row.

One reason I want to have a portal system with different levels (besides a Resi1 style game) is performance, since I primarily work with brush boxes. The alternative would be a large map with level streaming and classic teleporters within the map for the doors.

However, my knowledge is so limited that I don’t know which system I should use. I thought it would be extremely easy to connect two doors in two levels.

The easiest and fastest option is still to pass the next start location through game instance or open level.

Before loading next level, says where in the next level you want the player to be (hard coded):

At the game mode, you place the character where you specified:

Either pass the next location through the options (exemple above) or through the game instance.

PS: it would be better for the game mode to spawn the player directly where you want, instead of spawn and then move the character. But for now, this way works.