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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to create interactivity with a key in Paper2D?

So, my issue is that I want to make it so when my player walks in front of something I want the player to interact with, they can press a key, say [E], or in this case, [X], and I expected this to be a straight-forward process, but for some reason the system doesn't work the way I want it to, and I'm not too sure why. I've tried checking tutorials and other questions asked on the hub but all of them seem to be for such specific situations that they haven't been any sort of help. So, here's my blueprint, and my thought process.

alt text

alt text

So, when the player overlaps with the blueprint, which is in the place of the desk, (and also aligned with the players' position, that was the first thing I checked.) it then opens the gate that leads to the textbox widget that should show up when you interact with it. So, after the gate is opened, pressing [X] should enter the gate, and since it's now open, it should also exit the gate and add the widget, correct? I believe this might be an issue with the X input because everything else works perfectly, perhaps I'm not supposed to set up the input there?

If anyone can help me figure this out, I'd really appreciate it. Thanks in advance!

Product Version: UE 4.21
screenshot-5.png (79.6 kB)
screenshot-6.png (526.6 kB)
more ▼

asked Jan 28 '19 at 03:54 PM in Blueprint Scripting

avatar image

12 2 2 3

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

1 answer: sort voted first

I would go about this differently, I would use Interfaces so you can then interact with any object you wish using X and change the code accordingly. A good UE4 tutorial can be found here.

When looking at your code:

I would first debug it by watching where the execution is going/isn't. Also, I believe the Keypress logic you are doing is in the object so you would need to enable your Players Input by doing:

Enable Input

I recommend doing Interfaces, however, try the following if you need it to work and update with more information on where the execution is breaking.

input.png (47.1 kB)
more ▼

answered Jan 28 '19 at 05:11 PM

avatar image

116 4 5 8

avatar image Astro_dex Jan 29 '19 at 12:44 AM

Thank you so much! So, I decided to approach this in an entirely different way. This is now my code. alt text

I can't be 100% sure if you can read that, but put shortly, (this is inside the Player, FYI.) when the player overlaps with the object, it opens a gate to which the key X can be pressed to print the string and add the textbox to the viewport. Obviously, I don't want the player walking around while there's a textbox, that could cause bugs, so it also disables your input. So, while the whole system does work, I ran into the problem of not being able to simply enable input after you're done with the textbox, seeing as Widget Blueprints can't directly reference the Players' input. I'm probably not supposed to ask a completely different question here, and the answer probably just flew over my head, but I would like to know just for reference if I can make the widget enable input after pressing the button to exit. Just by logic, I can probably say it doesn't but I need an alternative because obviously, it won't be playable if you press X to interact with something and then everything freezes.

Your answer really helped, and I'd hate to take up your time with another question, but I just wanted to be safe.

Again, thanks. I've got my system working now.

screenshot-3.png (89.2 kB)
avatar image xXZUKINIXx Jan 29 '19 at 01:20 AM

Hey Astro,

You're welcome.

You can always thank by up-voting the answer if you found it helpful.

To expand on your second point, I think I understand it as the following:

You have a Widget that appears that is your Textbox and you want to be able to disable/enable the input? Other then putting triggers and button events on the widget itself, I believe you are looking for the following functions:

You can toggle these in your code so you can have the Textbox visible put then focus input on it when needed.

This is sort of a different question, but I think this will help. I am posting from my phone so can't give examples.

avatar image Astro_dex Jan 29 '19 at 01:40 PM

That is A-OK. Thanks so much again, I never really found the time to really learn the ins and outs of UE4, so this advice is very helpful. I'll try do some stuff with that soon, and if all else fails I suppose I can report back here, (but I doubt it won't work.)

Thanks... for the 4th time. Haha.

(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