Im bit of a noob and can’t figure out how can I make a checkbox to invert mouse settings. I’ve watched multiple Youtube tutorials that do it on ue4 and there doesn’t seem to be any for ue5/5.1.1 and the tutorials have not worked for me. Any help would be appreciated, Thanks.
Just * your current mouse axis data by -1
I guess he needs a boolean for player to toggle it.
The most efficient would may be to use a multiplier that is set when the boolean value changes so it is not set on tick :
I’d be glad to learn what is the best place to save this kind of player preference. I personnaly save it in the save game object and load in the game instance because that’s the only way I know, but I would have prefered an ini file for exemple or something else.
Are those both screenshots from the same blueprint?
Because it didn’t work for me, the checkbox is in my MainMenu blueprint and the mouse “viewment” is in my Player blueprint and it seems to not work because the variables are only in one of the blueprints.
Also what is the get IA_Turn_View in your screenshot?
Sorry for asking propably stupid questions and thanks in advance.
Also it seems that when i tried to cast to player, it would always fail and the command log and the cast to player shows no errors. Maybe this is the problem?
Yes I put everything in the same bp to illustrate the idea because I didn’t know where is your camera logic.
The multiplier should be indeed in you character since your camera logic is here.
IA_Turn view is simply the mouse axis, (gives from -1 to 1 when I move the mouse). It is the new input system, I don’t know which one you are using (New system allows having 2 axis values on the same event, the left one on my picture has his input splitted (right click on a pin and “split struct pin”)). Same event than the one on the right but with axis separated).
The “get” version can be used to get the value when your logic is not directly connected to the red input event (for exemple in a function). You probably don’t need it.
Then the cast fail, it means you have no character existing at this moment (or no character possessed by controller). When you are in your main menu and check the box, is it before launching a level, or while in the game map?
Im using the new enhanced input system and my input logic (Camera and movement) is in the character BP.
The Main menu is in it’s own level, which starts when the game starts and then i try to check the box, if that’s what you tried to ask.
Could the problem be the casting not working and you said something about the character not existing or not posessed by a controller? How could i check or fix this?
After i check the invert mouse checkbox in the main menu print string shows → cast failed. When i play the game i can control the character (Movement and camera), shouldn’t that mean that the character has a controller?
Again, thanks for helping.
Here’s some screenshots:
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)
Thank you so much, It works now.
And thanks for being spesific so a newbie like me could understand
No problem, it is sometimes hard to find the answer to a specific issue
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.