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"

Wait for Key Press bool then save level?

So I'm trying to create a level saving and loading system.

At the moment I have a saving system working as well as a loading system. My issue is extending the saving system to include a save data overwriting option.

I have a function to save the game which checks if the user has saved before. If they have, then it runs the overwrite function. as seen below.

alt text

Inside this function, it checks whether the overwrite bool is set to true. alt text

The overwrite bool is set via button press. alt text

If the overwrite variable true it should save the game, and if it is false it should create a new slot. However, when I get to the branch to check if the overwrite bool is true, it is always FALSE.

Is there any way to wait for a key press for multiple buttons?

I did try the node 'Is Input Key Down' but the overwrite bool check never gets fired. alt text

Product Version: UE 4.9
first save.png (117.1 kB)
overwritecheck.png (28.9 kB)
set bool.png (40.9 kB)
checkinputkey.png (96.8 kB)
more ▼

asked Dec 06 '15 at 10:13 PM in Blueprint Scripting

avatar image

7 3 3 7

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

1 answer: sort voted first

I think you have the programmer's blues running and are too fixed on the problem! :)

Don't wait for the key, let the key be the trigger for an action! So instead of starting the save process upon the player's "save now", you should do this:

  1. when the player triggers "saving game", you only do a check if the file already exists

  2. if it exists, you come up with the "are you sure you want to overwrite?"

  3. he then has to press one of two keys, so you set the variable then and then trigger the saving process (eg in a function)

  4. if he chooses a new savegame, you trigger the saving function immediately (step 2 and 3 not neccesary)

This way you have an asynchronous process without the need to do some akward check-if-the-player-did-something cycle in the background.

more ▼

answered Dec 07 '15 at 09:58 AM

avatar image

859 23 9 40

avatar image J_Issa1 Dec 07 '15 at 11:45 PM

@Enlo Would you be able to give me a quick example as I'm really hitting a blank here.

I've tried taking the save stuff out of the save function and put it into the Event Graph (to be able to add input). I've also tried using a gate (see below) to make the overwrite bool change but it never exits the gate? I'm assuming because it always ends up closed.

alt text

newsavefunc.png (150.7 kB)
avatar image Enlo Dec 08 '15 at 09:21 AM

The way you are trying to do this, the save action is triggered immediately. At this point, the user wont be holding down any key yet, because he simply does not know yet that he has to do so, right? You first have to tell him to press the key, before you check if he pressed it.

The root of your problem is, that you try to check user input and you tried to handle it like a momentary state. The problem with this is, that it is not defined WHEN the user presses the keys, so your logic may have run but you were not pressing the key at that very moment. So you need to wait on the user to press a key.

you have two [or more, hehe] ways to achieve this:

constantly check if one of the two keys is pressed inside Tick

While it works, you should try to avoid doing stuff in Tick, especially stuff that's not used often, since it's executed on every frame.

make your process asynchronous Only execute upon keypress

saveaction1.png (183.2 kB)
avatar image J_Issa1 Dec 08 '15 at 05:32 PM

@Enlo Thanks dude. I've managed to get it working. I guess I was just in a bit of a rut. You've been a big help, cheers.

(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