Announcement

Collapse
No announcement yet.

How do I use the same input for 2 actions in the same script?

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

    How do I use the same input for 2 actions in the same script?

    Hi, in the game I'm making, you are able to interact with objects such as open doors and pick up objects, which the key will be pressing E on keyboard and pressing left face button for controller. You are also able to reload, by pressing R on keyboard, but this is where I'm stuck, it's done by pressing and HOLDING the left face button on controller. Is there any way to distinguish if the input has just been pressed or if it's been held to determine the output? I thought it would've been an option in the Input settings page, like pressing a button while holding shift or ctrl, but it's not there.

    Thanks in advance!

    #2
    Is this ok for you ? Do this in your controller blueprint:

    Click image for larger version  Name:	1111.png Views:	0 Size:	107.0 KB ID:	1737498
    Key time Hold must be superior to the time you want the key hold. Change 1,0 with the value you need

    Comment


      #3
      Nope, this didn't work, I played around with the idea a bit too and couldn't figure it out, holding the button down does nothing, it counts as 1 input as soon as it's pressed and that's it, so the Event Tick isn't doing anything

      Comment


        #4
        You process all input in controller.
        Then you create event dispatchers to your events
        Then every actor that needs to know about such event connects to that dispatcher.

        Or if its singleplayer game, create dispatcher in some easily referenced blueprint like game mode, make dispatcher there, trigger it from player controller, and rest is same, all interested in event connect to that dispatcher.

        Comment


          #5
          Thank you, but I figured it out before I read that so I've done it bit different, but it works perfectly though so all is good, here's how I did itClick image for larger version

Name:	Controller-InteractReload-Function.png
Views:	15
Size:	145.0 KB
ID:	1737735

          Comment

          Working...
          X