I am writing a turn based two player game… and have been testing it via split screen. I am now running into problems with the HUD
Unreal automatically creates Player 0 (the first player) and I believe that we are to spawn all additional players in the blueprint. See screenshot below. Number of players is two and so we run the spawn player function once which runs the Create Player node carrying through the player number which is used to set the controller id. I have also checked Spawn pawn.
i now have two players in the game. Hooray!
My understanding is that Unreal automatically creates the HUD for each player when they are created. My HUD classes is a child of the default HUD class. In here i can draw simple stuff the screen such as the crosshairs. These show up on each players corresponding screen. On event BeginPlay of this HUD class I am running a function called Add Widget in which I am passing in a user widget and adding it to the players screen.
The new widget now appears on each player’s screen. Hooray!
The new widget contains three smaller widgets. On event Construct for each of these three widgets I am trying to set a variable to receive the game instance and the player’s HUD. This is where I am having problems.
See comments in screenshot. I have tracked through and we hit each of these widgets twice as expected - once for each player. I am able to cast the game instance to my game instance and store it as a variable for each player’s widget. I use ‘Get Owner Player’ which correctly returns each player but when i try to then grab the player’s HUD. I can only get Player 1s and not Player 2s. GET HUD returns nothing for Player 2.
If you have managed to read this far and I havent confused you, could you advise where I have went wrong in my process of if I am using incorrect nodes.
Many thanks!