Why does this cast always fail? Im trying to get the variables from Board_BP to my widget

https://img.onl/LHovSG https://img.onl/gRip56 https://img.onl/5WxMLu https://img.onl/molOp3 check those screenshots

What is ActoRef? You cannot create a ref variable and treat as it was already an actor.

  • if you create an integer and don’t tell it to hold a value of 10, it will be 0
  • if you create an actor ref and do not tell it which actor instance to refer to, it will refer to none - null

Besides that, if you had a valid ref, you wouldn’t need to cast. Casting is not a way of obtaining a reference. It’s a test telling whether the type is matching and whether the object is valid; it then converts the type, allowing you to treat it as if it was that type.

Your problem is not with casting, you do not have a valid reference, the cast is supposed to fail. There’s nothing casting can do here, but to warn you. Cast is your friend. :face_holding_back_tears:

Condsider explaing what need to happen. Which actor instance is supposed to update which widget, why and when.

So how do i display variable from Board_BP on the widget?

i mean i did everything he did in this video How To Make A Health Bar In Unreal Engine 5 - YouTube

Have the board create the widget, store a ref. Use the ref to push updates into the widget. This is a clean, event driven approach.

The widget’s job is to display what you send it. It should not look for data itself.

Widgets pulling data out of actors is like pulling teeth. Sometimes it’s a must, I’d avoid it.

Not all YT tuts are good. There, I said it :innocent:

Besides that, the person is using a character, a possessed pawn. You are not, right? Your board is not a character / pawn.

What they are doing with construct is OK but there are better ways.

Could you find me a good yt tutorial on this topic, or explain step by step? Im a big newbie in UE and, yes, my board is just an actor - board holds variable named MoneyPerSecond and i want to display that amount by a widget

I’ll do you one better:

  • this is a text block in my widget, we can expose it to access it directly, no bindings are necessary.


A little bit of script to update that text:

  • in the board actor; choose the widget class, right click the Return Value and promote:

This will create a type-correct widget reference variable this board actor can use to talk to the widget.

my board is just an actor - board holds variable named MoneyPerSecond and i want to display that amount by a widget

And talking is done like so:

Does this help?

idk man i did everything like you just described but it doesnt work https://img.onl/6tt1R4 https://img.onl/CXE51O

1 Like

im sorry for taking you so much time im just trying to understand

1 Like

Looks good! How do you call the update in the actor?

what do you mean?

How do you call this event? How do you change the value of that variable. Because calling this would update it and then call the widget’s update.


If you never need to update it, what’s the point of keeping it in the actor? You might as well hardcode a piece of text instead.

You can also connect these two if you want to see the value immediately when the game starts:

omg, it finally worked! thank you so much for your effort and time, i really appreciate it, by the way do you have some good “must watch” YouTube videos for total beginners? thanks again!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.