I am trying to cast to MyCharacter using Get Player Character, but the cast fails every because the Get Player Character returns nothing and I don’t know why.
So when you hook the last pin up, and play, the score stays at 0? Is it only doing it in this widget? If you make a BP, put it in the world, of event tick, print string your score via casting, does that work?
What if you Get Player Character in the Event Graph, and not in the function, does it work?
Or can you get a valid Player Character reference in the Level Blueprint?
You showed us “GameOver” screen so make sure you didn’t destroy your Player Character before you access a value from it.
I run the GameOver widget before I destroy the character and the text that shows up is empty it’s not 0 it’s just empty. I know the last pin is not hooked up in the screenshot but it is in the BP. I can’t do this function in the event graph because the purple nodes don’t come with it.
It seems to get the player character in the level blueprint with a print string. It just doesn’t work in the GameOver Widget.
How do I mark this as the answer? You solved the problem thank you very much.
Under your ‘tags’ in original question, choose ‘Close’ and choose closest answer.
Not the function, just try [Get Player Character] and [Cast to MyCharacter]. You can do in the the PreConstruct and save it to a variable, and then use it in the function.
Here you go, feel free to mark the question as resolved.
Glad I could be of help.