Casting to Game Instance from a dynamically created Widget

Hi all, just prefixing I’m still quite green with BP. Been stuck for a couple days.

What I’m currently trying to do is update a material from a dynamic list, see below for more info.

A question I have is it possible to Cast to a Game Instance from a dynamically created Widget? Right now it’s always failing… In my previous post here Need assistance using buttons created from a dynamic list using a struct - Programming & Scripting / Blueprint - Epic Developer Community Forums (unrealengine.com)
I got part of this successfully solved thx to @Everynone & @DomusLudus

Typically I’m able to Cast to the Game Inst , for ie

And here’s my current Game Inst

I know this is pretty sloppy (green) but I can’t understand why this cast will fail, the only difference here from an educated guess, is that it can’t cast from a dynamically created widget?

Any help/guidance would be awesome. Thx

Check your project settings.
Go to maps and modes and game instance should be near the bottom. You need to set it to your blueprint version “dinginy_inst”

Is your dinginy_inst set as the game instance?

Yup it’s setup there. Question should I even try to Cast in the situation or maybe try using a Dispatcher?

Well dispatchers a usually more reserved to a subscriber model.
Classes subscribe to the dispatcher and then listen in on when it broadcasts it’s information.

Have you stepped through the code (marked the blueprint with f9) and checked where the cast fails?

1 Like

Yeah it fails immediately, even like this

And when I do this, it returns nothing in the HUD,

Could I see your project settings?

Yup all good there, but as usual talking it out finds a solution!! This returns true!

So as an educated assumption by casting directly from a dynamically created object, you will have to make sure to grab its parent which is up another level?

Thx much for discussing it :slight_smile:

I’ll try this out.

~t

1 Like

You can also try Get Game Instance that is not widget related.

1 Like

As @3dRaven say , you have taken the “get” that is not

I think you should use the first

And if you allow me a tip about the last screen in your first post, I should take a look at working with data tables instead of using structures directly, it’s much easier to work with data. you just have to save the ID

1 Like

Hmm yeah I believed I used the 1st Get at one point and nothing happened? Yup I’m using tables, this struct is from another solution I had in the previous post I mentioned. Thx much for replying, I’ll try the 1st “Get” again.

~t