How Can I Make a Button Only Press When a Certain Number of Objects are Collected?

I’m using Blueprints, and I cant seem to figure out how to do this.

I’ve looked on Google and every answer I’ve found I haven’t been able to follow.

I’ve got numerous ‘gems’ hidden and scattered throughout my level, with a UMG HUD displaying the total number of gems that I have. I’d like a certain button in my level to only be accessible when, say, 20 gems are collected.

Any help will be greatly appreciated. Thank you.

Hm, no. I want to be able to press a button only when I have a certain amount of collected items. So if I tried to press the button with none, nothing would happen. When I’ve collected the set amount, the button becomes functional.

I don’t understand, you want to know how to make a button visible/invisible?

So, the set amount is a variable, right? Simply use a branch in your button function, use the gem amount variable as condition, so the button function is true when gem amount ==20
Or do I miss something because it’s very basic

Forgive me, I’m very new to Unreal.

The set amount isn’t a variable, no. How would I go about making it a variable?

Thank you.

Agreed with learning the basics. Believe it or not I’ve learned quite a bit in a week. And am enjoying it. (;

Anyway, here are the screenshots:

I think my current main problem is figuring out what nodes to use and where.

Thanks again!

You should start learning basics, there’s a lot of beginers tutorial on youtube.
Can you post a screenshot of your hud blueprint and the blueprint where you have the function of collected gems if it’s not in the same blueprint? If you can get how many gems you’ve collected, you already have this variable somewhere.

Hey there,

You’re going to want to do the following:

  1. Add a button to your UMG Widget (Center it however you’d like)
  2. Click on that button in the Designer, and go down to Events on the detail tab
  3. Click on the OnClicked Event to create a new event in the Event Graph
  4. Cast to First Person Character and make a branch to see if you have the required gems
  5. Add functionality

Hi Mookiez.

A button in the UI wasn’t quite what I was going for. However, with the blueprint you provided I was able to implement that into an in-game button. With a few tweaks. And it works great.

I can’t believe I couldn’t figure this out.

Thank you so much!

“A button in the UI wasn’t quite what I was going for”.
You ask for a “Button Only Press When a Certain Number of Objects are Collected”. Do you mean a gamepad button? If so, go to your controller blueprint and paste the same logic that Mookiez posted after your gamepad button event. Then, the button will react only when the condition is equal to 20

Forgive me, it was 4am at the time.

The answer given was exactly what I needed.

I thank you both for taking the time to help me.