Player Controller Possess Event
How do you determine when a PlayerController has possessed a Pawn? Is there an event for this?
My PlayerController creates a HUD widget on Event BeginPlay. The HUD then needs to draw information from the Pawn that is possessed by the PlayerController. The problem is that the PlayerController doesn't have a possessed Pawn at that stage. UE4 seems to set up the Pawn possession at some point after the PlayerController is created, which makes sense. I would like to "listen" in for that event so I can respond at the moment that UE4 assigns a Pawn to the PlayerController. Then I can notify the HUD of the new Pawn to start drawing information from to display. If at some point during game play the PlayerController changes Pawn, I can then also respond to that using the same event to notify the HUD of the new Pawn.
asked Oct 31 '15 at 12:11 AM in Blueprint Scripting
Guys, in C++, you should override AController::SetPawn method. It is the only virtual method that is guaranteed to fire as soon as the controller possesses a pawn.
answered May 10 '17 at 10:32 AM
maybe there is some smarter way but in any case you can create a event dispatcher and when you override the specific functions in your gamemode you can call the event dispatcher at the right time
(ue4 spawns a default pawn specified in your gamemode and you can override those specific functions inside your gamemode)
by the way why not create the widget from your hud class specified in your gamemode ?
Follow this question
Once you sign in you will be able to subscribe for any updates here