Check if variable is a certain integer?

I wasn’t able to find the answer on a Google search so I’m asking it here.

I want to show my widget saying “Gems: 500/500” if the player’s “Mount Fox Gem” variable is 500. I have the widget and the blueprints already increase the variable correctly, but I can’t figure out how to make a check if the variable is a certain number.

I also want it to run once so the widget appears for a few seconds and disappears.

Any help would be appreciated :slight_smile:

When a player gets one of Gems fire an event to LevelBlueprint to check if player has earned all Gems (if Gems earned == 500). If true show your widget

Not sure where to type in the number 500.

You’re converting your integer to a bool which means that if the integer has a value of 0 it will return false and any other value will return true. Drag off the integer variable and search for greater.

Tried that.

Seems to always fail its casting to my player character blueprint for some reason.

Use “Get Player Character”. The “Cast To” nodes are a bit special in that they ask if the object input is of the same blueprint class, if they’re of the same class the cast will succeed and you can use any information related to that blueprint class. If they’re not the same blueprint class the cast to fails. In your case you’re asking if the Player Controller at player index 0 is of the blueprint class SheilatheFox.

Edit: If you drag off the “Get Player Controller” node and type in “Cast to” you will see what you can cast to from that node.

Thank you - it now shows up the widget. :slight_smile:

Now to make the widget disappear after a few seconds. I think that I should use a Delay node for that?

Remember that the “Delay” node does not reset it’s countdown if it gets called again, the “Retriggerable Delay” node does.

Thank you :slight_smile:

The widget does not seem to show up for some reason.

You’re creating a new widget so you need to add said widget to the viewport. Also the current setup will add a new widget each time it’s called, but you will only remove the last one you created.

I added it to the viewport and now it appears once I have all 500 gems, but as you said, it just loops.

I tried doing DoOnce but that didn’t work for me.

Where did you put the “DoOnce” node?

I put it after “create widget”. Putting it before made it fine.