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.
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!
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:
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.
Thank you so much! So, I decided to approach this in an entirely different way. This is now my code.
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.
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.
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.