Creating one USE key for multiple events

Hi there,

I’m completely new to UE and have been slowly bumbling along, watching tutorial vids all week but have hit a snag.

I want to walk up to a light switch and turn on multiple lights at once using ‘E’ - DONE!
I also have a secret door that’s activated when you press ‘E’ on a book.

My issue is that the way i have set up begin+end overlap to Enable + Disable Input means that when i enter ANY trigger box and hit ‘E’ it will trigger the secret door to open… so not that secret when the light switch opens the door

I assume there’s a way of isolating the ‘E’ key to only work on what triggers are near by???

Any help would be fantastic, but a picture of how to fix this would be amazing!

Cheers,

Jim



If you already follow Epic’s light switch tutorial, the next step would be “blueprint communication” tutorial.
Which you still accept event ‘E’ for a book setup like a light switch, but instead of doing anything, you call a custom event that defined in your secret door BP that opens itself.
Where do you get this relationship then? you can save a reference by create a variable that is an instance(object with _C in name when you choose variable type) from your secret door BP.
OR, if it’s only level specific, you can use event dispatcher and BIND the book’s event to secret door’s open event.

Go check the tutorial if above is not clear to you, as you would need those knowledge to understand.

Thanks for the help PenguinTD. That tutorial helped me fix my ‘one switch for many lights’ issue by referencing push “E” inside the switch blueprint and the lights (in another BP) as opposed to in level blueprint
845bd25d7232c46f60bb920522a9f2e010154059.jpeg

Im now stuck trying to get my secret book (with matinee that makes it move) to open the secret door (obv a matinee as well) within class blueprints. I know im going to want to make more switches using ‘E’ in my level and dont want the same issue of one ‘enable input’ trigger box activating every ‘E’ triggered matinee. So I tried making another blueprint switch that references my level blueprint matinee sequence but I cant reference a custom event in the level BP in my class BP. Is there another way to talk to level BP matinees or events in class BP’s?

Addition: Is there some way to isolate or add a condition to the ‘E’ pressed function that will make it work exclusively with the trigger box im in and not EVERY trigger box in the level??? Sorry but never used Unreal or any level editor until this week. Thanks!

If you want to have a lot of different interactive objects triggered by the same button press, it may be best to create a Blueprint Interface function for it. The setup in the tutorial using level script and toggling player input is really only useful for a one-off situation, and not a good way to structure things if you want a lot of interactive objects for a game. Ideally, you’d want to keep all your input events inside the player pawn Blueprint and use one function for all interactions of a particular type.

So, once you’ve created an Interface function, you can go into your player pawn and call it like this:

This is going to try to call the Interface function on all actors currently overlapping your pawn when you press E, but only Blueprints containing the corresponding Interface event will actually do anything.

Next, in the Blueprints for your interactive objects (such as a light switch or button), you need to click the “Blueprint props” button at the top, then add your Interface asset in the Interfaces section. This will allow you to add events for the interface functions, like this:

So, if this Blueprint is overlapping your player when you press E, that event will fire and you can hook up whatever toggles or timeline animations you need to it to do. The final thing you’ll need is to include box or capsule components in your interactive objects to use as overlap triggers, so when your player is overlapping the component they can interact. There are a lot of examples of that set-up in the Blueprint_Communication Content Example I made, specifically in example 3.2.

With this kind of structure you don’t really need to use the level script at all, which is handy if you want to have a lot of interactive objects and don’t want to have to set up triggers and events for every instance of them.

1 Like

Ok, I think im getting the idea behind what you’ve said above:
Player Pawn (MyCharacter) says when the player is overlapped and ‘e’ is pressed, send this through to the BPI
The BPI intermediates with other BP’s by sending this info through to my class BP or sequence of matinees in level BP,
thus keeping ‘press e’ commands out of the level bp.

So I created a Blueprint Interface


and then made your first picture set im my ‘MyCharacter’ pawn.

This is where im lost. I can go to a class BP and add the BPI with props but i cant create an "event Interact’ as in your second image.

Sorry but I’ve only started using UE this week :confused:

Cheers for all the help!!!

You’re on the right track - once you’ve implemented the Interface in the interactive Blueprint’s properties and compiled, the events for its functions should be available in the right-click context menu, but they’ll be named the same thing as your Interface functions. So in this case, search for “Pushed button”. There are a couple of instances where it won’t be available, however, such as inside certain functions - Interface events have to go in the event graph itself.

Ok now where was I. FANTASTIC! I’ve successfully used this to do away with the [ON/OFF overlay>>INPUT/OUTPUT<<<getplayercontrol] part of my downlight and wall switch setup. I’m guessing I’ll have to try and emulate my matinee actions (of the book sliding and tilting backwards + the secret door retracting then sliding to the side) as timeline animations in order to reference/create then inside a BP (cause you cant call a matinee in a BP for now). If this is correct then my last question on this matter is this: What IS the point of matinees at this stage? Im honestly asking so I know how best and when to use them.

Thank you once again Thomas.

Cheers,

James.

I think the main reason Matinees are used for the beginner tutorials is that it’s easier to grasp, letting you manually move meshes and playback the animation to see exactly how it’ll all look. They’re really more for cinematics, or environmental sequences like, say, a collapsing bridge, or some other event that would require moving a lot of actors around together.

Timelines unfortunately don’t give you any sort of preview and need more manual setup, but the upside is that you can use their outputs for a much wider range of things besides just moving objects around. It’s ideal for things like doors and levers, where you just want something to move in local space. If you set up a door Blueprint with a built-in trigger and a Timeline for opening, for example, you can re-use it all over the place without ever having to do any extra set-up, which isn’t possible when using Matinee.

Yeah I can see in the examples with the swinging door how that would be important. I’ve also found a way to reference a matinee in a BP through a variable: https://answers.unrealengine.com/questions/9122/is-it-possible-add-a-matinee-to-a-saved-blueprint.html

I believe this is technically a bug… please don’t remove it though! :slight_smile: It’s exactly what I need!!!

Thanks again!

James.

Hello

I am actually setting my character’s events against hum… all the world ^^ and your question and your answers are really helpfull to me so thanks a lot.

Even more than a year later this helped! Thank you so much Thomas and James!!! :smiley:

I have blueprints problem with E key functions and other BP’s with the same. When I hit E “not overlapping” anything, it still plays all BP’s at once in the world. Why? Is this the same bug since 4.6 and “fixed”(not really).?
I also have Cast To FirstPersonCharacter on every begin and end overlap.???
Please help. Thanks