I got a game, where I have two characters, MyCharacter and MyCharacterSideview. The player can swap between these two, and it gets different functionality from the each.
The MyCharacterSideview should have a HUD as well, which I was able to add to the Viewport, but I cannot reference this caracter in the widget blueprint. And this way, I cannot get any variables into my HUD from the player.
For testing I even tried to cast it to the other character (just in case, I missed something) but both casts fail.
The picture attached, is in the Widget Blueprint itself, referencing to both player pawns; both fail.
In any other part of the game, casting with the same method to the same player pawns work.
What am I missing?
Oh, one more thing. Yesterday I did set this up, I was able to assign a function to a button, so the cast was working… then I had to leave, so shut the computer down. After returning, it wasn’t working.
You could reference the widget in the pawn blueprint and send variable values into the widget instead. This is more efficient in the long run compared to binding values in the widget itself.
In relation to the test on the included image. Are you sure the pawns are spawned and possessed at the time “Event Construct” is run? You could make a timer to trigger the check repeatedly to be sure the timing is not an issue. It will also help to confirm what is possessed at the time of a check.
With referencing the widget in the pawn blueprint… well, you lost me there… but, you had a point with the timing!
I have added a delay of 1sec, for testing, and the cast worked as it should.