Coin Collection UI Displays Duplicated Text

Title: Coin Collection UI Displays Duplicated Text

Brief Description of the Issue
At the start of the game, the number of collected coins is displayed on the screen as “Coins = 0.” However, when the player collects a coin placed in the stage, “Coins = 1” appears overlapping below the “Coins = 0” text.
(Only the number is stored as a variable.)

I have tried various solutions but have not been able to resolve the issue. I would appreciate any help you can provide.

Details:
◆Creating the Widget
1)I created a simple UI in a Widget Blueprint to display the number of collected coins.
※Components:
・Canvas Panel
・Image
・Text [WBP_Coin_Count]

2)I initially set the “Text” property of Text[WBP_Coin_Count] to “0.”
3)I checked “Is Variable” for Text[WBP_Coin_Count] and created a Text-type variable.
4)I named this asset “WBP_Coin.”

◆Coin Blueprint (Displaying the UI)
1)In the BeginPlay event, I connected “Create Widget” and set the Class to “WBP_Coin.”
2)I promoted the “Return Value” from “Create Widget” to a variable and named it “WBP_Coin_02.”
3)I then connected “WBP_Coin_02” to “Add to Viewport.”

◆Coin Blueprint (Updating the Coin Count Variable)
1)In the ActorBeginOverlap event, I connected “Destroy Actor.”

2)After that, I retrieved “GM Coin Num”, a variable previously created in GameMode to store the coin count, added 1 to it, and stored the updated value back in “GM Coin Num.”

3)Then, I connected “SetText (Text).”

※Additional Notes:
・For the Target, I referenced “WBP_Coin_Count” from the “WBP_Coin_02” variable.
・For “In Text,” I converted “GM Coin Num” to text using “ToText (Integer)” and connected it.

◆Debugging Feature
After “SetText (Text),” I added a “Print String” node to display the current coin count using “GM Coin Num.”

※Additional Notes:
As far as the print strings are concerned, the variable “GM Coin Num” just stored the number of coins.

Sounds like you have more than 1 widget. Could show how you create the widget and add it to the viewport?

◆Coin Blueprint (Displaying the UI)
1)In the BeginPlay event, I connected “Create Widget” and set the Class to “WBP_Coin.”
2)I promoted the “Return Value” from “Create Widget” to a variable and named it “WBP_Coin_02.”
3)I then connected “WBP_Coin_02” to “Add to Viewport.”

Which BP is the above in? How many actors like that are in the scene? Look for places where widgets are created. Perhaps there is also a widget component somewhere that also instantiated a widget?

1 Like

Thank you very much for taking the time to respond to my rather clumsy post.
However, I must sincerely apologize for the considerable delay in getting back to you.

Shortly after posting about the issue, I began experiencing difficulties connecting to the internet, and my computer itself was also not functioning properly. As a result, I was unable to send you a reply in a timely manner.

As for the issue I had raised, I’m pleased to report that I was eventually able to resolve it on my own.
I’m truly sorry for any trouble or confusion I may have caused you.

Should the opportunity arise, I would be delighted to speak with you again.
Thank you once again for your kindness and support.