How to set max value size? (Bombs)

OK so I have some bombs (blueprint) laid across my level. Here is the bomb BP.

d958074f897f477451ba6cd55c8cb702e9523b14.jpeg

So as you see, when the player moves over the bomb BP, the object goes away and +1 is added to the HUD counter. Works great.

Here is how I calculate the values of the bombs collected for the HUD.

ThirdPersonCharacter BP stores the value

And this widget BP shows the value to the player on screen.
589544bf4fe580a9ef7a3482bc06e4abf93a6aa6.jpeg

Everything works perfect. Player walks over bomb, bomb goes away, and the counter adds +1 on screen. Great.

Now I need to be able to set a MAX Bomb value. I want the player to only be able to collect 10 bombs, when the counter reaches 10 players can still walk over the bombs and make this go away but the counter goes no higher than 10.

I also have this BP called bomb_explodes.
dd1cd486a9065da032fdc8896c040399b129f6ca.jpeg

What happens in this BP is that when the player presses the E key a bomb is dropped. I need this BP to check the value of the HUD counter and only allow the player to drop this BP item if the counter is 1 or Greater.

So how do I do this, detailed steps welcome.

You already solved your problem.
Just put a branch node (if) into your script

It’s the same: If counter >= 10 then counter set to 10

ok first lets focus on getting the bomb_explode blueprint to drop via the E key when the bomb count is 1 or greater.

This is what I have and it isn’t working, not sure if I am doing this right, I figure I need to cast to the ThirdPersonCharacter BP to get the value of bombs stored, then check if that is 1 or greater, but I think I am doing it wrong.

I also added the branch node like you said but not sure if in the correct area. Screenshots or detailed steps would be greatly appreciated.

I’m not good at programming, but you have nothing cast from the ThirdPersonCharacter node, and there is nothing connected to the branch condition after the AddBombs node.

To have a max bomb limit, to my mind the easiest solution would be to add a “clamp” node in the AddBombs function - https://docs.unrealengine.com/latest/INT/BlueprintAPI/Math/Integer/Clamp_int/index.html

So after the Addition and before the Set, insert a Clamp node which takes the output from the addition, and clamps to range of 0 and 10 (0 ensures you can’t go negative if you accidentally call the function with a negative number of bombs). Then send the output of the clamp to the set.

That way, as long as you always use AddBombs to increment the bomb count, it will never let you go above 10 (or below 0).