Why is this not working? Trying to collected coins and have widget count it.

bind is connected to text in widget

Hey @ddave104!

Try putting in some print strings at different points to narrow down where it’s getting hung up. For instance, off of the “Cast Failed” of your Bp_Projectile, and after the “SET: Coin Counter” node. If the cast is not failing, and it is indeed going through the set coin counter node, try setting the printstring’s value to the output of the coin counter.

Give that a go and let us know what happens! :slight_smile:

2 Likes

I put the print strings down and

  1. the cast did not fail

2)the SET is going through

  1. the coin counter print string is going to 1 but when I hit another coin in the level it remains 1

I also put a print string in the bind (widget), connecting it to the return value of the ToText(integer) node. It continually output 00 even when hitting the coin.

cant say this is the issue but you dont want to use bindings for this anyway, create a function in your widget called AddCoin which adds 1 to coin counter and then immediately SetText to the new value

it looks like that code is on your coin which means you have 1 widget per coin (ie duplicates, so it probably is working its just being overwritten) when only one should exist. the widget itself should be created on your pawn or controller so only one instance exists

1 Like

@ddave104 Hello, I have recently started learning Unreal 5, and worked on a system gathering orbs.

The way I structured it, would be to set the code on the orb BP, along with a blueprint interface as a communication method and the code on the orb would go like this:

OnActorBeginOverlap→Does implement interface→Branch node and from True→ Call the interface function. I would also set an input parameter on the interface function to set the value to 1.

Then on Player state (Just so that when my character gets destroyed, I wouldn’t miss the orbs), I would, create an integer like orbCounter, just so that I would save the value.

On the player character, I would call the interface, cast to player state to get the orbcounter→add the value of the interface with the current value which we got from the casting and then set it and that’s it.

Also, I agree with @Auran131 , it seems taht you are creating the widget over and over again by creating it in the coins. So yeah, I would create it in the player Bp maybe (I do not remember where I did it) and on the bing I would just cast to player state to get the current value.

I will try to upload some images to make it clearer once I get home, because I am at work and UE5 has nothing to do with it :D.

PS.Please excuse any mistakes about the nodes or anything else structurally, I am very early on the learning stage and raising a 1 yo baby at the same time ;).

1 Like

Looks like you forgot to add this widget to the viewport.

Thank you

1 Like

Hi! Did you try my solution? Unfortunately, i didn’t get to upload my images yet, too busy with my son last two nights, but I hope I explained it well enough to help.

Yes I did it marked your as the solution, thanks again