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"

How to return player back to where they were after opening a door

Hey, I'm currently working on a project and have hit an issue and I'm not entirely sure how to tackle the problem, I'd very much appreciate any help from the community!

Alright so I've made a door blueprint, you push F on the door and it loads a new level - when you push F on the door from the second level to load back into the original level you spawn at the player start. I'm going to have a lot of doors on the original level and was wondering how would I make it so that the player would spawn in front of the door they originally opened on the original level?

Can I achieve this through blueprint or will I require the use of C++?

Thanks in advance!

Product Version: Not Selected
Tags:
more ▼

asked Sep 29 '14 at 07:17 PM in Blueprint Scripting

avatar image

CookieCaster
6 1 2 3

avatar image eXi Sep 29 '14 at 09:51 PM

Hm, you could save a position when using a door.

I would try to add a variable for a position to my doors and if i use the door, i would save the position to a variable that survives the changelevel and than port the player to this place.

But, hm, i guess there could be a much better solution to your problem.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hi CookieCaster,

Use a blueprint of a trigger volume or billboard that you can set in front of the door to allow the user to load to that specific point.

more ▼

answered Sep 29 '14 at 09:07 PM

avatar image CookieCaster Sep 29 '14 at 09:36 PM

The problem is more that there'll be multiple doors in each level, but I do not know how to have a door in one level bring the player to a specific door in another level. For example, a player opens the door to a house which loads him into the house interior level, I want the player to be able to use the backdoor to load into the outside level again except behind the house. I thought about maybe having a Boolean value which turns true when the player uses it, and then iterating through all of the doors checking for the bool so the player is moved to the location of the door, but that didn't work.

avatar image Adam Davis STAFF Sep 30 '14 at 08:10 PM

What may work is to save the value, though. You save the value of the specific location you walked through (lets say a trigger volume. Then when you walk back in, you send them directly to the saved value. If you enter another door, save the vector value of that one. Repeat as necessary.

avatar image Mordecai May 27 '15 at 09:12 PM

Adam,

How would you go about saving the value of that specific location? I have doors with box triggers in front of them, that when interacted with the player by pressing E > Which opens the assigned level. What kind of value would I apply to that trigger and how would I go about using it?

avatar image Adam Davis STAFF May 28 '15 at 03:02 PM

You would want a vector, so for example lets say trigger A is at 0,0,0 and it sends you to level 1. Well when you press E in trigger A, you want to set the vector variable Return_Vector to 0,0,0. When you come back to the loading area use "Set actor location" to the vector "Return_Vector" on level load. You can use the "Return_Vector for every trigger and just set it to the trigger location each time you load a new level so that when you return you always return to "Return_Vector", which is set to whichever trigger you used.

avatar image Allegro Jun 17 '15 at 08:20 PM

You'd want to just store that vector manually in your triggers, wouldn't you?

Assuming that you start in a hall with multiple doors... you go in one, storing your return value, and then you enter a third room, and once more store your return value... if you return to the second room, having once again stored a return value, you'd have overwritten your ability to enter the main hall and would be returning to the third room again...

If you store the vector manually on each trigger, then they would just always take you where you need to go.

I spent a long time trying to figure out the level open "option" it appears to be undocumented. I also spent a bunch of time trying to figure out the "tag" on Playerstart... I'm assuming that there's no way to select a player start when running level open? That we are expected to use teleport instead?

avatar image Mordecai Jun 19 '15 at 04:40 PM

Okay, so I have been trying this out and I am kind of lost (yeah, I admit it -_-)

So I have a couple questions (please know that I have almost zero knowledge on how programming works (i'm working on it)):

If you want to set it so when the player presses the E key inside of a trigger and have it store the vector:

  1. Do you want to SET the Vector when hitting E? What does this do exactly?

  2. Do you want to GET the Vector when hitting E? What does this do exactly?

  3. Do I put the GET or SET after the Open Level Node, or after (or does it even matter)?

  4. How do I go about storing this Vector? Do I make it it's own variable (Vector) and use the same variable for each trigger, or do I create a new variable for each trigger that leads to a new level? Is there a way to check if the correct vector location is stored?

  5. Since I want the player to go back and forth (as if they are going through a door and back through it), would each trigger need it's own SET/GET?

I apologize for all my questions, but I want to make sure I am doing this correctly and efficiently. I really need/want to learn how to do this right.thank you

avatar image Adam Davis STAFF Jun 19 '15 at 04:57 PM

I can answer most of these pretty quickly by explaining what a get/set are. It will make a lot more sense then.

A set variable node takes a variable that you have and sets it to whatever you tell it. So basically, in our case you have a vector variable, and a set node says "Vector A, you are now this location".

A get variable, in contrast, grabs the variable and uses the value that it is. So a get will look at a vector and take whatever data that is already present in the variable.

In our case, we want to set the variable when pressing E to force the "Return Vector" variable to be the triggers vector value. I haven't tested this directly, but I believe storing the return vector in the player would be the best choice. The reason is that you can save the players variable values when transferring levels. When you return, you can cast to the player and grab the vector, which should still have the value you are looking for, then simply set the player to the location. This is just the way I do it though, I believe Allegro's suggestion of storing the vector in the trigger should be possible as well.

To answer the question Allegro had, I think it is possible to select a player start, however you have to use the get all actors of class on level loaded and select which one you want from there. This is on my agenda of stuff I haven't tested but theoretically should probably work.

(comments are locked)
10|2000 characters needed characters left
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