Options Constructor

Documentation

Features

  • Game ready options system - contains all basic options and is easily extendable.
  • No plugins required - the system is created in blueprints. Can be accessed and changed on demand.
  • Single component - everything is stored and handle through single manager component.
  • Premade widgets - a bunch of widgets blueprints to speed up creating your own settings.
  • Keymapping system - supports primary and secondary keys. Additionally, can be used with modifier keys (ctrl, shift, alt, cmd).
  • Saved, loaded and stored locally - whenever options are changed they are automatically saved and stored locally. When a game is loaded options are loaded and applied as well.

Implementation

1. Add OptionsManager component to your player controller. If you don’t use custom player controller blueprint then you can add it to your character/pawn blueprint.

2. Add AnyKey event to the blueprint with OptionsManager and connect two functions to it. To "Pressed" pin connect "UpdateHeldModifierKeys" function. To "Released" pin connect "Rebind Key" function.

3. Make BP_GI_WithOptions your default game instance class. It can be set in Project Settings in Map&Modes tab under Game Instance category. If you already have your own game instance then just make it be a child of BP_GI_WithOptions.

Add new options

1. Inside Enumerations folder find enum corresponding to the option you want to add.
  • Open "E_OC_BooleanOptionType" to add new checkbox/switch based options.
  • Open "E_OC_StringOptionType" to add new text based options.
  • Open "E_OC_FloatOptionType" to add new number based options.

2. Create a new function that will be called when option state changes. You can create it wherever you want as long as you can access it, however, I’ve added and grouped all “Apply” functions in OptionsManager. To keep it consistent you may want to create new ones there as well. If needed you may create new categories or regroup existing ones.

3. Depending on the created option navigate to the corresponding function. Hook up newly created function to empty pin in SwitchOnEnum node:
  • boolean based option – ApplyBooleanOption function
  • string based option – ApplyStringOption function
  • float based option – ApplyFloatOption function.

Edit options


1. Open options data table (DT_Options), it contains all available settings. These options will be applied to the game if you wish to not use few of them just check off Active state. Additionally, except Active variable each option also has DefaultState. You can edit all the options. Eg. You can add more elements to AvailableStates array in Resoultion option.
  • Active - determines if the option is used in the project and should be applied to the game
  • DefaultState - determines the default state of the option, this state will be applied when a player hasn't defined his choice yet or when options are reset.

2. Boolean options can also disable/enable other options. Just add specific options to variable "OptionsToDisableOnChecked". Eg. When MuteAll option is checked on it will disable all volume sliders, because moving them wouldn’t affect the volume at all.

3. Float options have few additional variables.
  • MinValue and MaxValue - determine bounds state bounds.
  • Steps - determine how many steps slider should be divided into (if <2, the slider will move smoothly).

TIP! For Resolution option, you can also use resolutions supported by a system instead of the ones you put in the data table. You can enable it in AC_OC_OptionsManager component (variable UseSystemSupportedResolutions).

Add settings widgets to the project


To use options widgets in your menu or user interface you just need to add them as any other widget. Visually they all are quite simple, but you can easily change each of them and add your own graphics and style. You have few types to choose from: checkbox, combobox, cyclebox, slider and keymapping box.

Apply and reset options


1. By default whenever option state changes it will be automatically applied to the game and saved locally. It can be changed in AC_OC_OptionsManager, under General category check off ApplyOptionInstantly.

2. To apply or reset all options on demand use functions: ApplyAllOptions and ResetAllOptions. You can tie them to UI buttons. Resetting all options will set their state to the "DefaultState" defined in "DT_Options".

3. Options like Bloom or Motion Blur have to be applied to the specific camera. Use "SetCameraReference" function to specify to which camera options will be applied. Ticking "ApplyOptions" will instantly apply current camera options to a new camera.
Note: Each time you change controlled pawn, character or blend view with a new target you need to reset camera reference and reapply options to that camera.

4. Options Constructor provides 6 premade sound classes, they are already hooked up to the volume control functions.
  • Assign all imported sounds to these classes so they will be affected by associated sound class volume.
  • Master sound class is the parent of the other 5 remaining sound classes. Setting its volume to 0 will mute all sounds.
  • Alternatively, you can create your own sound classes and swap references in functions they are used in.

Keymappings and rebinding


1. Create keymappings in Projects Settings as usual. You don’t need to assign buttons to them. Open DT_Keymappings and create the same keymappings there, this time assign desired buttons.
Note: Mappings names in DT_Keymappings must match the ones in Project Settings.

2. To use the rebinding system with counter-axis input (like default character movement) you will need to create 2 separate keymappings (one for positive value and one for negative). Check the video below to see how to set it up.

3. If you use the button that is already assigned to another keymapping, the system will automatically remove it from the old one and assign to the new one.

4. Action keymappings support mapping with modifier keys (ctrl, shift, alt and cmd). Modifier keys cannot be used with axis keymappings.

Premade widget types


1. CheckboxOption widget is used to add an option that requires a simple switch to make it enabled or disabled. Eg. Toggle fullscreen, mute sounds.
  • OptionText – a name of the option, text will be displayed to the player.
  • OptionType – defines which option is affected by the widget.
  • UseButtonToToggle – if enabled whole widget will be used to toggle option state, if disabled only precise checkbox clicks will toggle option state.


4. SliderOption widget is used to add options that require an adjustable value. Eg. Volume controls.
  • OptionText – a name of the option, text will be displayed to the player.
  • OptionType – defines which option is affected by the widget.
  • SaveValueOnlyOnCaptureEnd – determine if the value should be saved and applied only when player releases the slider handle.


2. ComboboxOption widget is used to add an option that needs more than two options to select from. It is built on top of the default combobox widget. Available options will be displayed in the list. (Eg. Resolution)
  • OptionText – a name of the option, text will be displayed to the player.
  • OptionType – defines which option is affected by the widget.


3. CycleboxOption widget shares the same data with ComboboxOption widget. It means you can use cyclebox or combobox to affect the same option. Depending on personal preferences you can use cyclebox for few options and combobox for others, all up to you.
  • OptionText – a name of the option, text will be displayed to the player.
  • OptionType – defines which option is affected by the widget.
  • UseArrowsToCycle – determines if option should be changed using arrows. If disabled it will use the whole widget as a single button.
  • Loopable – works only with UseArrowsToCycle option enabled. Defines if a player can cycle through options over and over.


5. Add KeymappingOption widget to rebind key of single action. Use as many of them as you need.
  • OptionText – a name of the option, text will be displayed to the player.
  • ActionName – the name of the Action or Axis input which will be remapped. Note: It must match input name in Project Settings.
  • UseSecondaryKey – determines if the secondary key can be remapped as well.
  • KeymappingType – determines if remapped key is action or axis input.