Announcement

Collapse
No announcement yet.

Creating one USE key for multiple events

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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

    https://www.dropbox.com/s/rwqcja1gb7...2016.43.52.png
    https://www.dropbox.com/s/m4j5ockaxt...2016.44.08.png
    https://www.dropbox.com/s/sm0ikf1evx...2016.44.24.png

    #2
    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.
    Unreal Engine 4 Game Framework diagram for relation of all major base object types
    Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
    Resident Evil Classic Camera
    RPCs official document, Must Read
    Everything you should know about replication

    Comment


      #3
      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
      Click image for larger version

Name:	JimsSwitch - fixed.jpg
Views:	1
Size:	201.1 KB
ID:	1050614

      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?

      Click image for larger version

Name:	Level BP custom event wont work in class BP.jpg
Views:	1
Size:	189.3 KB
ID:	1050615

      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!
      Last edited by GenotypeJim; 05-14-2014, 09:02 AM. Reason: Adding question

      Comment


        #4
        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:

        Click image for larger version

Name:	Interface message.jpg
Views:	1
Size:	62.9 KB
ID:	1050628

        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:

        Click image for larger version

Name:	Interface event.jpg
Views:	1
Size:	58.6 KB
ID:	1050629

        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.

        Comment


          #5
          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
          Click image for larger version

Name:	Blue Print Interface 'pushed button'.jpg
Views:	1
Size:	212.7 KB
ID:	1050633
          and then made your first picture set im my 'MyCharacter' pawn.
          Click image for larger version

Name:	Mycharacter use key setup.jpg
Views:	1
Size:	86.9 KB
ID:	1050634

          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 :/

          Cheers for all the help!!!

          Comment


            #6
            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.

            Comment


              #7
              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.
              Last edited by GenotypeJim; 05-16-2014, 11:12 AM. Reason: no ref to spam needed!

              Comment


                #8
                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.

                Comment


                  #9
                  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/que...blueprint.html

                  I believe this is technically a bug... please don't remove it though! It's exactly what I need!!!

                  Thanks again!

                  James.

                  Comment


                    #10
                    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.

                    Comment


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

                      Comment


                        #12
                        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

                        Comment

                        Working...
                        X