Download

Trying to make button in widget kill player

I am trying to make it so that when you press a button on a widget the player character dies. I have been having problems trying to get it to work so does anyone know how I could do it. Thanks

Hi,

Well showing some screenshots or at least telling us what you are doing would be helpful.

If you have a KillPlayer function on your Character, and you want to call it from your Widget, you need a reference to the Player. The easiest way to do it is to get it form the PlayerController, as it holds a reference of the currently possessed Pawn.

So in your widget:
GetPlayerController->GetControlledPawn->CastTo(MyPlayerCharacter)

You take the returned reference from the cast node, drag it and and search for the KillPlayer function.

If you don’t know what casting is, or how it works in Blueprints, take a look at this:
https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/CastNodes/