Hello all!
I have an EndGameUI Widget Blueprint, and I want it so that when it shows up, player movement is disabled. What I’ve done:
- I have a SetNoMove function in my Player Blueprint.
- I have created a Player variable (type Player, i.e. my Player Blueprint) in my EndGameUI Widget Blueprint
- I used GetPlayer to be able to call SetNoMove from within EndGameUI’s EventConstruct
Unfortunately, I am still able to control movement when the UI shows, and I get an error in my log “Blueprint Runtime Error: “Accessed None trying to read property Player”. Blueprint: EndGameUI Function: Execute Ubergraph End Game UI Graph: EventGraph Node: Set No Move”
You haven’t set the Player
variable to anything, so it’s just a reference to nothing. You need to obtain a reference somehow. There are many ways to do that.
Is the Player your main player?
If so, this should work:
- In your WidgetBlueprint, Create a “Get Owning Player Pawn” node.
- Connect its output pin to a “Cast to YourPlayerBlueprintName” node.
- Wire the Cast node’s Exec pin directly to “Event Construct”.
- Add a Set node for your Player variable
- Connect the output of the Cast node to the input of the Set Player node
- Connect the output Exec of the Cast node to the input Exec of the Set Player node
- Connect the output of the Set Player node to the input of the Set No Move node
- Connect the input Exec of your Set No Move node to the output Exec of the Set Player node
Your Widget Blueprint should look more or less like this:
2 Likes
Thank you for your help! I got it working!
For reference, my Player Pawn was a Player, but not a Player Character (I’m still too new to appreciate the difference), so it worked without needing to Set the Player:
I just used “Player Character” as a example for your class name. Did you create a new class named Player
? I know there is a built-in class named Player
, but that’s for networking.
Also, I recommend storing the reference in a variable so you don’t have to do the Cast more than once. (It’s not expensive to run, I just mean it makes the graph look prettier.)
1 Like