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?

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 :smiley: i hope this helps!

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!

Works perfectly! Thank you :slight_smile: 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.

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

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.

Here is an other way to do it , using timers