How do I possess a character from Widget blueprint?

I’m trying to possess a character that I have placed in the level already, which is fairly simple via the level blueprint, except I’m using a menu and need to do it the via the Widget blueprint, I don’t know how to make reference to the character.

Please help! Thanks in advance.


theres several ways to get the reference and its all really dependent on your setup as to which one you should use. but heres a few ideas, you could use a public variable thats set via the details panel while in the editor, you could use a line trace to again set a variable, or you could use the get all of class node which isnt advisable.

the below pictures are two examples on how you could accomplish this task.

the first picture shows a method where you have a reference to the pawn to be possesed in the level bp and you use that to set a variable in the game mode. then in the widget you just need to get the game mode and get the variable. this will give you a reference to the character so that you can posses it.

the second picture shows how you can set a variable in the widget when the widget is created. basically you use the create widget node, then drag off of the return value (this is a reference to the widget that could be made a variable for use later) and search for the variable you created in the widget.

this is just a few ways to accomplish this and there are many more out there. give us a bit more info on your setup and i can come up with something more tailored to your specific case.

It’s just a simple set up with 3 characters in the level selected by menu options - your first example worked. Thank you!