lately i asked a question about casting and it seemed that i got my answer, but now i am really confused.
Can someone explain me in detail what i should do so my cast never fails again ?
and btw, i created the widget “new” in level blueprint so i cant get the variable since i cant cast to it.
thanks.
In this case you don’t need casting. Your “New” object is already of the type you are casting to so you don’t need to cast. Casting is used when you want to use an object as a different type (they need to be with child/parent relation to each other). Your error is something completely different I believe it’s from the GetDataTableRow node returning None and you trying to set that to the variable
Now that I read the error, it’s because your object “New” is actually empty, you never set it to be anything anywhere. Before using it you need to actually set it as something. That’s a widget right? You need to get a reference to the actual widget on the screen and set that as the variable or the engine won’t know which widget of that type you want to set.
This is how I do it, when I’m creating the widget to be drawn on the screen I set it to the reference so I can call functions or change variables inside it later on.
Well there are many ways you can go about this. The simplest would be to get all widgets of class, get the one at index 0 (assuming you only have 1 widget of that class) and set that to New. If what you’re trying to do is in the player bp you can also just get the player character in the level bp, cast it to your character and set the New variable that way directly in the level bp.
No, the problem is with the object, i tried this and it showed me the same error :
You’re right about this one, but in my case i have a problem,
I created the widget in my level blueprint and since i can’t get variables from level blueprint what should i do ?
I unchecked (top level only) in get all widgets of class and it worked for me, thanks really usefull .