Widget buttons require clicking twice to register action?

Hi all,

I have a widget that has two buttons. each button is bound to an event dispatcher that is called when the either button is clicked.

the buttons determine a characters stats list. the list is determined by a text field that is fed into the “get data table node”

When the game loads i have to click the buttons twice to remove the widget and spawn the next one.

I don’t think the issue is a focus issue as the game registers the first button click - i know this because if i click the first button then the second button, the stats will be that of the first button click

I think the issue lies with the data tables as if i bypass them the issue goes away. i have screenshots of the blueprint, as well as the function for the “Get monster stats from DT” function - any help would be greatly appreciated!

Thanks all

First things first:

This is dodgy and even if it works now, it may stop working later. You’re accessing data that may be stale. You have a ref variable, use it.

Must we use Get All Actors of Class? It will not be reliable if there are 2+ actors. If there’s only 1, why use it at all?

I’m new to Unreal Engine so this is just the way i learned how to access variables in another BP - can you explain how i can do this better?

Thanks

Not without knowing what is what. Currently we know nothing about what spawns what, how and when - Base Monster Class, for example and the blueprint you’re showing. What kind of actor is it?

When the game loads i have to click the buttons twice to remove the widget and spawn the next one.

Sounds like you could have 2 widgets, one of top of another. Is it possible there is more than 1 instance of the BP shown?

if i bypass them the issue goes away

Perhaps the DT does not find the row? We do not see how you set the Name variable. Print it to see what the initial click is actually trying to look up in the DT. It could be an issue with the order of execution. You dispatch the click first and then Set the name var value. That would explain only the 2nd click delivering results.


Also, when you dispatch calls, you can add data directly: