Setting Up the Default Inputs

The first thing to do is to create a setup script which will run once before any of your other scripts try to get input from cInput. Note that this setup script only needs to run once, so if you put it in the first scene the player will see (e.g., a splash screen or loading screen) then you don't need to include it in any other scenes. cInput will persist when changing scenes.

It is considered best practice to call Init() in your Awake() function to allow cInput to instantiate a GameObject and load any customized settings. After that, you can define all of your default settings in the Start() (or other) function, starting with defining actions with SetKey() followed by any axes with SetAxis(), similar to what's shown below:

More details on how to use SetKey() or SetAxis() can be found in the Script Reference.

Remember: An axis cannot be defined until after its actions have been defined.

For a full list of acceptable inputs (as strings) see the Valid Inputs section. Additionally, you can use the included Keys class to let autocomplete help you type in the correct keys. Many of the examples in this documentation take advantage of the Keys class.

Last updated