Hi there, still a noob at Unreal Engine and I have no idea on what to put in the “object” wildcard for a user widget.
This is what blueprint looks like;
Please help.
Hi there, still a noob at Unreal Engine and I have no idea on what to put in the “object” wildcard for a user widget.
This is what blueprint looks like;
With casts you are always casting an instance of something to a different class. So for instance if you needed to get the owner/parent of that widget you could use the helper for that and connect it to a cast of the type you expect so that you can access all of it’s specific properties and methods.
Happy to help more but would need more info in what you are specifically trying to do.
I’m trying to cast to “Controls”, but I don’t know how because I don’t know what to put in the “object” wildcard of the node, I can’t get the actor of class because its a user widget so pls help.
What are you trying to cast to “Controls”?
No I don’t know what to connect to the object wildcard
what to connect to the object wildcard
The object you want to cast.
Casting is not a way of finding something - folks often treat it as if was. Casting is more like a test - to see if what you’ve got can be used in a specific way.
But you need an object first, then you can cast it (treat it as something else). If you do have an object, you will, most likely, not need to cast at all in the first place.
So…
Controls
- where / when / how did you create it?Controls
- another widget?If you have that info, you will be able to find your objects.
The cast node needs an instance, the editor does not know which one you mean. What if there are 4 Controls? Which one do you want to test?
If someone comes along and suggests you use Get Actor / Widget of Class
, avoid their advice like wildfire. It’s not the right way to learn how things work and will get you nowhere.
So a cast is what you use when you have one thing and you are pretty sure it is more specifically something else, so you want to treat it like that and access those extra variables/functions. So for instance, if you did a find for actors with a tag that you knew you put on say a sheep actor in your level. You would take the reference to the actor that was found (which would be of type Actor
when you got it from the find) and you would connect it to a cast to your sheep class (say BP_Sheep
, so Cast To BP_Sheep
). Then you would know if the execution at the top without a label ran that it was of type BP_Sheep
and could use the BP_Sheep reference from the As BP_Sheep
that would be at the bottom to access say a function that would make it eat grass. However, if the Cast Failed
labeled execution ran you would know that the actor was NOT of type BP_Sheep
and you could pop up a message or ignore it or whatever you needed to do in that case.
Is Controls a widget in your UMG you are trying to access?
We don’t need philosophy, we need answers…
Sure. Reference stuff properly. Done. You don’t even need to cast then.
What you call philosophy is the core of OOP. You can’t code without knowing it.