That explains why the cast fails, your character is not in your menu level (which is quite normal).
Your Character is probably assigned here, in your game level (more precisely to the game mode assigned to the level) :
Or maybe you spawn manually the character then possess it, but anyway you don’t have the character in the menu level. You could assign the character to the menu level game mode to make the cast work, but since these are 2 different level, the value changed in the character will reset when opening the game level (and you probably don’t need this character in your menu level anyway).
Concretely.
You should use the Game Instance (which is persistent across levels) to transfert a data from one level to an other one. To create one, right click in the content browser->blueprints->search “game instance” (the one in blue on the picture)
:
Once created, it needs to be assigned to the game in the project settings :
Then open it and create your 3 float variables sensitivity X, sensitivity Y, and vertical invert (or whatever you name it). By the way you have only one slider to control sensitivity, you should either make two different sliders (one for x and one for Y) OR use only one (depends if you want your player to be able to tweak both axis).
Once you have your game instance class with its variables, lets see the widget.
I have two separate sliders here :

And the code for the widget :
With that setup, the values set in game instance during the menu level will be kept and you can reuse them in the game level.
Here is the code in the character :
That should work like this, however you have to think if you have access to this settings menu during the game, it will just change the values in the game instance but it won’t update in the character (since the begin play is already passed). But you can still extend the code in the widget blueprint :
Like this it will always write in the GI, and update character if there is one.
EDIT: I forgot to add the nodes for the mapping context on the character begin play (no need to cast to controller here)






