Passing Variable to a Widget

Hey everyone, I’ve done this multiple times in the past but working on something new where I have 6 pawns(6 players) instead of 1. On begin play I’m counting the number of checkpoints on the level and setting this via a variable called Set TOTALCHECKPOINTS

On my widget I simply want to display this number at the top

It works fine if i set the variable on the PAWN BP and then call it in the widget, the issue is I have to reference Player_1 in my widget, but I’m going to have 6 players and I need all players to see the same widget.

If I try to set this variable and call it from any of the ACTOR BP
s I have it fails to display anything. The object requires a connection but I have not found anything that worked except Get Movement Base Actor which is not right. Anyone have an idea how I can try to accomplish this? Again I’m going to have six pawn BP representing the 6 players.

Sounds like this could be solved with basic inheritance.

All your checkpoints, if they at all need to be different BPs, should extend the same parent BP. That way you can just use a single “Get all actors of class” node (as it counts child BPs as well) to get the amount of checkpoints.

Same for your players and widget. Assuming you at all even need 6 entirely different BPs for your player pawns, just give them the same parent BP (which should contain the logic for having the total amount of checkpoints) and then cast the owning player pawn to that parent BP inside your widget.
Alternatively, have all pawns implement the same interface with a function for retrieving the total checkpoints.

Additionally, and this isn’t relevant to your current problem, but the amount of checkpoints sounds more like something to save in the GameState.

Awesome, thanks for this idea going to try this out and see if i can make some progress with it. Appreciated !