And this widget BP shows the value to the player on screen.
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.
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.
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’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.
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).