Sometimes casting drives me crazy (rookie)

Hi

Actually, I’m casting most of times with no major complication, but sometimes I find myself stucked with situations like this one:

This Blueprint creates a widget and inmediately stores it in the variable Widget. I expected to have access to the event dispatches in the widget reading from that variable. BUt, you see the capture, I can not.

But if I “cast to itself” then I do have access to those dispatchers. Look:

Why do I have to cast this?

And, apart of not understanding why, it’s not working. When I try to use this “re-casting” method to be able to read the dispatchers, like this

It compiles, but Cast fails! Cast to himself and fails LOL But I need to cast to get access to the widget. Crazy.

If someone gives me a clue or leads me to the right documentation or tutorial I’d be lifetime grateful.

Hello again, Tuerer

I was right now finding that same thing in this tutorial


I assumed (wrong) that promoting the variable on widget creation would e create the right type of variable automatically.

I’l test it tomorrow as soon as I dive on the project, but 99% odds this is my mistake.

Thanks again!

You’re doing something wrong. Did you promote it to variable after or before you selected the widget class? Because if before, your variable is of User Widget class and of course you can’t access your custom variables and event dispatchers.

In the list of variables to the left, hover the cursor over the variable pictogram. It should read “W Image Seq Mouse Dist”, not “User Widget”. If not, change its type to your widget class. Then you’ll be able to access all its elements without any casting.

Yeah it was that mistake. My knowledge about variables is as deep as about casting.

Promote your answer to reply : )