Console Variables In Unreal
Console Variables are powerful tool that you can use to change the game at runtime. This means you can do it at any point in the editor or in the live build of the game without needing to reload or recompile anything. This has application in both debugging and in the final build of the game the players will use (although most games will restrict player access to it).
The Console
There are two main ways of setting console variables, one temporary and one more permanent. The temporary way is the way you will use most of the time. To do this you can open the console either by clicking on it at the bottom of the editor window or by pressing the ‘`’ key (top left of standard keyboard, below Escape). If you hit this button a second time it will open up the full console window. Using the bar at the bottom is useful as it suggests console commands as you type, although bare in mind that not all console commands show in this way, so if a command doesn’t pop up, try it anyway.
The format that you will use in the console will either be a toggle such as ‘Unit FPS’ which will turn on and off each time you type it in and does not need any other input, or one that requires input, such as ‘sg.ShadowQuality 4’ which needs the console variable followed by a space and the input, in this case setting the Shadow Quality to Epic. Commands can also take multiple inputs, separated by spaces.There are a few variables that have different ways of entering them based on if it’s in the engine or a build of the game such as the ‘Show Flags’. In game entering ‘Show SkeletalMeshes’ will toggle making Skeletal Meshes visible or not, whereas in engine the game command would be ‘ShowFlag.SkeletalMeshes 0’ to hide them and ‘ShowFlag.SkeletalMeshes 1’ to make them visible again. There are many commands and variables of them, a good website to use to find the correct ones is pongrit.github.io.
Config Files
Using console commands directly in the console will only apply those settings for the current instance of the editor, so when you close it and reopen it, everything will return to default. To do this more permanently we can change the ‘.ini’ files, usually located in the Engine > Config folder. Different config files can overwrite each other, usually relating to different platforms, so ensure that you understand your project’s config file structure. In terms of the default Unreal structure the main thing to remember is that project and platform settings overrule the base engine config files, so if you change one file and it does not have the expected effect, it may be being overwritten elsewhere.
There are different config files in these folders that do different things such as ‘DefaultEditor.ini’ which changes the editor and ‘DefaultGame.ini’ which changes builds of the game only. In these files you will find a list of all the console commands currently being applied. There are a bunch as default and a project will often have added plenty more. You can see the formatting of these console commands are slightly different to typing them directly into the console. The input, rather than separated by a space, has an equals symbol and no spaces. For example rather than using ‘sg.ShadowQuality 4’ to set the Shadow Quality to Epic you could enter ‘sg.ShadowQuality=4’ into the DefaultEngine.ini file to ensure that it always opens Unreal Engine with Epic Shadow Settings.