x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Pressing a Key in front of a door to enter in a new Map

I'm creating a game with a main outside level and some interior ambient levels. The idea of the game is look like some old 5th gen games, like Silent Hill, where do you press a key/button in front of a door and you get teleported right to the other side of that wall, without any opening door animation, but a black and quick load screen.

Doing it inside a map looks a kind of easy, but right now I want to do it between levels. My door is in the outside map, I want to press the key "E" in front of the door to make my character appear inside the place, exactly where the door should be inside.

alt text This is how I want it to work. Press E in front of the silver door behind the chimmey to appear in that room. Press E in front of the red door to appear under the stairs.

Well, I don't even know how to start. I already tried some stuff with Blueprint that I found searching here in the forum, but it didn't help me.

Product Version: Not Selected
Tags:
ask.png (291.0 kB)
more ▼

asked Apr 07 '15 at 10:37 PM in Blueprint Scripting

avatar image

Mairon W
16 2 5 7

avatar image Spiris Apr 07 '15 at 10:50 PM

I would recommend using a blueprinted gameinstance and playercontroller in order to achieve this, as well as a few well placed PlayerStarts. You can use the standard 'open level' node to get to you new level, passing an index that points to which player start you want to spawn on to your game instance depending on which door you used. After the level loads be sure to place your player at the proper playerstart and you should be good to go.

avatar image Mairon W Apr 08 '15 at 02:05 AM

alt text This is what I created in here, and of course, it didn't work. I can use the door as the teleport blueprint trigger or I should create a trigger box where the character must be inside when I press the E key? Like I said, I don't even know how to start this.

ask2.png (64.6 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

This may not be the best way, but you could use a game instance, a door actor, and your level blueprints to start off.
The game instance would need an integer value to identify the door you will arrive at in the new level.
For your door blueprint it could look something like this:
alt text
Here we check if the player is in range, then we set the target for the next level by changing the variable in our game instance and move the player to the next level.
Then your level blueprints would have to look something like this:
alt text
Here we loop through all of the doors you have set in the level, and we check if we have a match from the door we came in from. If we do, we move to a child component's position and rotation so that we don't spawn inside the door itself.
You will need to fill out your variable defaults, set up id's for your doors, as well as target id's to match the door id's of the level you move to.
Hope this helps!

doorbp.png (117.3 kB)
levelbp.png (133.3 kB)
more ▼

answered Apr 08 '15 at 05:26 PM

avatar image

Spiris
1.1k 41 35 76

avatar image Mairon W Apr 08 '15 at 06:49 PM

Hey man, thanks a lot! I understood the logic. But I have a really little newbie problem: In the "Set Door Id" there is a node for "Target", how can I create that node?

avatar image vanlacke Apr 08 '15 at 07:14 PM

That variable is in his MyGameInstance BP, hence he needs to reference that BP in order to set the Door ID

avatar image Mairon W Apr 08 '15 at 07:32 PM

Sorry. I couldn't found where it is or how I can create it. alt text

It will work this way? I'm using UE4 in Portuguese, so some words are translated, like "SET" to "DEFINIR".

ask3.png (84.0 kB)
avatar image Spiris Apr 08 '15 at 09:47 PM

That way will not work. You want to cast to your own game instance, inside that game instance's blueprint you need to declare a public integer variable, which you can then set in the way my blueprint did.

avatar image Mairon W Apr 09 '15 at 03:37 AM

My problem right now is: when I create a node from "As Game Instance" I cannot set a variable for the Door Id. It simply does not show my variable when I write "Set".

avatar image Spiris Apr 09 '15 at 04:35 PM

First you need to creat your own GameInstance blueprint. Then you can create the variable you will get later. Here is a shot of the variables in MyGameInstance
alt text

Here is an example of how to get that variable later.
alt text
Beyond this, I would highly recommend looking up some documentation and watching the some tutorial videos on blueprints. They are filled with valuable knowledge that will save you a million headaches.
I wish I knew Portugese so I could help you better understand everything that is going on here. I hope that what I have given helps!

avatar image Mairon W Apr 09 '15 at 05:27 PM

Perfect!! Thanks a lot, now I got it. I will do some tests with the IDs now. Sorry to ask too many questions, but for now, you will certainly be in my game credits haha

avatar image Mairon W Apr 09 '15 at 06:47 PM

alt text This is the door outside, the blueprint exactly as you did and the values of the variables. alt text This is the door inside the map "1floor" and the Blueprint for "1floor". The GameInstance that I created just have the variables. In the three BP the value for all the variables are the same.

And, it didn't work. I put my character in front of the outside door, I press the E key, but nothing happens.

ask5.png (335.8 kB)
ask6.png (333.1 kB)
avatar image Spiris Apr 09 '15 at 07:17 PM

In your OnComponentBeginOverlap event you need to set PlayerInRange to true, it currently is being set to false.

avatar image Mairon W Apr 09 '15 at 08:15 PM

Still not working /=

avatar image Mairon W Apr 09 '15 at 09:56 PM

In the Level Blueprint. In "Get All Actors of Class", the Actor Class is of the door from the outside or the inside? And the "My Id" variable, works for what?

avatar image Spiris Apr 09 '15 at 10:23 PM

The actor class in an ideal situation would be the same class for all of your doors, they may have different models and textures, but they all stem from that class. The My Id variable is the id that you assign to the door, give it a default value like 1 or 2 or 0, but make sure you set your target id in your other door to match it.

avatar image Mairon W Apr 10 '15 at 05:28 PM

Ok, now I figured out that when I delete MyGameInstance from the BluePrint, it works, but the character do not start the new level where it should be. I think the problem is with the GameInstance.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

It works fine .I think you dont have change your GameInstance in your Project settings

more ▼

answered Feb 21 '17 at 01:46 PM

avatar image

Aratorn76
1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question