Announcement

Collapse
No announcement yet.

Picking Up An Item - Logic For Holding Button In For x Time Before Allowing Pickup

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

    Picking Up An Item - Logic For Holding Button In For x Time Before Allowing Pickup

    Hi All,

    In my game, a character can find an item and pick it up and store it in his inventory.

    Currently the character is able to pick up and store the item however when I walk up to the object and press the button to pick up the item, it picks it up instantly.

    What I am really wanting to happen is for there to be a delay while you are holding the key in before the item is picked up (kind of like charging the pickup and when it reaches a certain level it calls the pickup action).

    Below is a screenshot of my blueprint. Can someone please assist with the logic here?

    Click image for larger version

Name:	Untitled.jpg
Views:	1
Size:	124.6 KB
ID:	1142716

    #2
    Hey,

    i tried to recreate some of your Setup, but a bit is missing. I guess you will still see what you could do:



    I used the tick event to count from 0 to 3 when as long as i press "i" (or your PickUp Key). If i release the key or didn't hit something, i set the bool to false.

    You can also use the Timer variable for a UMG progress bar or something.

    It can be, that the setup needs some improvement or that a Gate Node would work here too, but this works for me i hope this helps!
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    Comment


      #3
      Hi there, yes I left quite a lot out as I figured the problem would probably be somewhere here.

      Thanks for your help though, going to relook at it tonight and take your advice into account!

      Comment


        #4
        Originally posted by eXi View Post
        Hey,

        i tried to recreate some of your Setup, but a bit is missing. I guess you will still see what you could do:

        I used the tick event to count from 0 to 3 when as long as i press "i" (or your PickUp Key). If i release the key or didn't hit something, i set the bool to false.

        You can also use the Timer variable for a UMG progress bar or something.

        It can be, that the setup needs some improvement or that a Gate Node would work here too, but this works for me i hope this helps!
        Works perfectly! Thank you My only problem now is that when I do pick up an item and there is another item in close proximity to me, that one also gets picked up.

        Comment


          #5
          I just use delay to be sure the player is still holding the button, like this. I think, that's the easiest way.

          Click image for larger version

Name:	2015-01-09 18-19-02.png
Views:	1
Size:	55.3 KB
ID:	1065004
          [My FREE stuff] Custom Cameras (Stategy, Orbital) | Sticker Note | ESC Inventory System | Pipe Generation (Spline based) | Procedural spline-based Mesh generation | Homing missile
          [My Market stuff] Advanced Aim Component | Lock/lockpick Component | Blueprint-based Key Remapping System

          Comment


            #6
            Originally posted by VitriolicZA View Post
            Works perfectly! Thank you My only problem now is that when I do pick up an item and there is another item in close proximity to me, that one also gets picked up.
            What you need to do in this case is to add some sort of bool (I'm guessing you have followed the UMG tutorial available on the UE4 launcher or have some other "in range" check to see if you can pick up the item).
            I would suggest expanding the system by getting all the actors of the pickup type and only allow the nearest of those actors to be picked up (if that's how you want it to work).
            I myself have changed a lot from the tutorial so I add items by looking at them and pressing the LMB.
            Kind Regards,
            Bonny

            Comment


              #7
              Here is an other way to do it , using timers
              Click image for larger version

Name:	0001.PNG
Views:	1
Size:	101.3 KB
ID:	1065006
              Website [ LINK ]
              Twitter [ LINK ]
              Support ! [ LINK ]

              Comment

              Working...
              X