How do I make sure a player can't pick up two objects at the same time?

How can I do this pick up system? I have been trying to create a system that allows the player to interact with (basically pick up except they don’t actually pick it up) an item, and when interacted with it creates a widget above their head of the item interacted with. I want to make it so that when they have a widget above their head, they can’t interact with other items until they “put the object down”. I have set up this pickup event and blueprint interface which is working correctly


I also have this in the blueprint of the object they are picking up, which will delete the object and creates the widget when the player interacts with it

Is there any way I can update this so that when the player is picking up one item, it won’t allow them to pick up another item? I have tried some ways, but they don’t work due to the fact the objects are spawned in later on, so I can’t access global variables for them in the level viewport as they are not placed in to start with.

1 Like

Consider the following:

  • have the interface return some form of Item ID so we can track what we have:

Here it’s a user widget soft class reference. It can be some other ID but since you want to track it with widgets and we already create them anyway, we could use that.

  • the collectible actors return their type:

  • the player has a Set variable where they track what they have (think of it as of a very rudimentary inventory / tracker):

A Set :point_up:, by definition, can only hold unique entries.

Note there no longer is any script in the pickup items - no need to duplicate script for every object class.


The above is a pseudoscript, I never run it but it should :crossed_fingers: work.

-famous last words

1 Like

Thank you so much for your help! It is working better now, the widgets are showing up and everything, but I’m still having the issue that the player can pick up multiple things at the same time!

Double check what the interface returns inside the actor.


Could you clarify what you mean by “at the same time?” Do you mean you can pick many simultenously or the same item many times?

Id setup a “held in hands” variable on your player class or inventory component whatever you may be using. On interact, check whether it is empty or not and pickup or not accordingly

As in when I pick up one item, the player still has the ability to pick up another item, however I don’t want this to be possible!

Thank you! I’ll try this

Does it mean you can carry only 1 item at a time? Because that was not clear at all. I was under the impression you wanted to carry 1 item of each type.

For one of each type:
Compare current w/interacted pickup

For only one at a time:
On pickup disable interaction until item is used or dropped.

Yes only one item at a time, I apologise for not making it clear

Thank you!

It that case, may I suggest you completely discard what I suggested and simply add a single boolen variable instead. Query it when picking up an item and set it to true if successful.

I have tried that but I’m not very experienced in coding and didn’t manage to get it to work, I’ll try that again though thank you!

It’s just this then.

1 Like

Thank you very much! Seems like a simple solution so I’m embarrassed I didn’t figure it out myself, but I this is my first project using Unreal Engine and I’m relatively new to coding, so I appreciate the help

No one ever talks about sets, I thought I had my chance to talk about sets. :innocent:

1 Like

:laughing:

1 Like