Casting to another blueprint in the widget visibility graph

System:

I have set up a system that will display a widget dependent on a variable. If the variable returns true, the widget will become visible, and if the variable returns false the widget will become hidden. This system works perfectly when I am referencing to the Third Person Character as casting is very simple with the third person character. (I can just use get player character for the object):

Issue:

The issue I am experiencing is when I cast to a different blueprint other than the third person character. For example an actor, the widget will remain visible (which is it’s default state) meaning that it doesn’t recognize whatever I am casting to the blueprint variable so it can’t return true or false. I’m not sure how to cast to another blueprint, and non of the tutorials online have been helpful unfortunately. This is a picture of the blueprint I am using:

Any help would be appreciated, thanks!

You need a reference to the object you are “casting” to. So in your case “WoodInventPickUp” needs to have something fed into the object pin hence the error. Your cast will always fail the way you have it set up. Use an overlap or hit event or other such event to get the reference to the “WoodInventPickUp” and you should be fine.

In other blueprints I have set up a overlap or hit to get the object event but in the widget blueprints, this doesn’t seem to work. How would I go about doing this?

You must be “collecting” this inventory item somehow and then calling the function in the widget BP. So what you need to do is wherever you are coding that “player has picked up inventory item”, whatever event that is should store a reference to the actual object. Then you need to create a path from widget to that blueprint to get the reference OR whatever BP calls this widget function you could just add an object as an input and give it directly to the function from the BP that calls this widget function. So for example, say in Player BP you have an overlap event that identifies the object overlapping the player as a “pick up” item. You then call this function by referencing the widget in the Player BP. What you can do is “add input” to the function in the widget to receive an “object” reference and as soon as the player overlaps the item within the Player BP call this function and drag from “overlapped actor” into the newly created “input” on the widget function and the rest will take care of itself. You can use that object input in the cast.

I hope this is not too much to ask, but could you show me how this would look if it was set up correctly in the proper blueprints?

This is the set-up I was referring to. But to be honest, this is a pretty bad set-up for what you are trying to do. You will be making a new function for each “pick up” or you will have a long list of “casts” in one function, like “cast to wood” if fails “cast to stone” if fails “cast to gold” etc. What you probably should do instead is just have a parent “pick up BP” and that parent BP gets a reference to the inventory widget so when you overlap the “pick up” set widget visibility to “visible” and when finished overlapping “set visibility to hidden”. But for your specific situation if you want it how you currently have it this is how to do it.

I’ll try both solutions and see which one works better. Thank you! You’ve been very helpful (I have been stuck on this for so long) .

Hi, I know I’m getting back to you late but I recently had a hard drive failure and I’ve just been able to test out the solutions now. Unfortunately I can’t seem to find out how you got the custom visibility function working, if you can, could you help me with that?

It’s a function you create in the widget I just named it “custom visibility” that’s supposed to represent whatever you wanted to do with the visibility.