Set Visibility doesn't work

I want an orb image in my UMG widget to disappear initially in-game and then once the player collects all 500 gems of the level, the orb image appears on the widget.

This is my blueprint:

I am currently testing it with 0 gems just so I am sure it works, but the orb image still appears.

Any help would be appreciated. :slight_smile:

You’re not casting any object :slight_smile:

I tried Get Player Character but it still shows up.

Have you verified it’s going down the code path like you expect using blueprint debugging or a print statement?

Are you sure you’re referencing the correct image widget? In your first picture you have 3 image widgets. Also if you just want to have the image hidden from the start. Go to the designer tab, select the image and go to Behavior > Visibility and set it to hidden there.

I did a debug by linking the “Cast Failed” to a “Print String” which prints “Cast Failed!”.

It’s not the problem with the image but it is a failed cast. I need to cast to “Sheila the Fox” or I will get an error about a mismatched targets.

Managed to fix it by following the simple step in here - Direct Actor Communication Quick Start Guide | Unreal Engine Documentation
Casting always seems to be unreliable in UE4, for whatever reason.

There isn’t anything unreliable about casting in UE4 and I see a lot of devs making this mistake on this forum. The “Cast to” node is actually a thing in programming called “Type Casting” or “Type Conversion”, you can look it up for clarification on what it’s definition is. Here is an example of how it’s used in UE4 blueprints:

[Get Player Pawn] -> [Cast To “CustomPlayerBlueprint”] -> [DoPlayerEventOrGetPlayerProperty]

You see, the Cast To node changes the type (Or it’s class) from the Get Player Pawn reference to CustomPlayerBlueprint because CustomPlayerBlueprint is a child actor of pawn.h. If CustomPLayerBlueprint is NOT a child of Pawn than the cast will always fail. Maybe the UE devs could look into making a note or something in the future for the cast to node to explain it’s function a little better.

Edit:
In your situation I see [Get Player Character] and a cast to SheilaTheFox. Let me ask you this one question: Is SheilaTheFox parent class Character.h? I’m guessing it’s not? Good luck :slight_smile:

“Sheila the Fox” is the blueprint class for the player character and stores the different movement nodes. So I used Get Player Character as an object of “Sheila the Fox”. That seemingly didn’t work, but creating a variable which references to “Sheila the Fox” works fine.

I’ve tried something too similar than your case and for me works perfect.

a) Like “TheFoyer” suggest check if is a class of Character in class settings
b) Make sure if “Sheila the Fox” is the Default Pawn Class
c) I expect “FoxSurfMenu” is the right instanced widget and default value of “MountFoxGemExploration” is “0”…

Anyway if I were you I change your goal sending a “message” after collecting Gems, and you save a unnecessary check every tick, just for that case doesn’t matter but at the end of the project sure you save resources and get better performance.

When making mods, there were a lot of Doonce conditions to ensure that everything was optimised.

I actually did away with Set Visibility and instead decided to change the text color of the buttons, depending on progress. Of course, such a thing only needs to be done once. :slight_smile:

> “Sheila the Fox” is the blueprint class for the player character and stores the different movement nodes. So I used Get Player Character as an object of “Sheila the Fox”. That seemingly didn’t work, but creating a variable which references to “Sheila the Fox” works fine.

That doesn’t quite answer my question. If you open your blueprint in the top right you should see parent class. If this is your player’s character then it should be of type “Pawn”. In that case you need to get ‘get player pawn’ node

change the cast to sheelaTheFox node to a pure cast. You use pure casts when you are NOT changing a variable inside the cast to node. You are getting a variable value, therefore you are not changing anything