General Input

General input is for handling input that is not specific to a vehicle, such as game menu navigation, and can be placed anywhere in the scene.

To create your own general input script, create a new script that extends the General Input base class:

using VSX.UniversalVehicleCombat;

// Custom general input script 
public class MyGeneralInput : GeneralInput {}

Initialization

When an input script is initialized, it means it has access to all the components it needs to control and is ready to run.

General Input scripts are initialized by default, but you can override the Initialize function in your own scripts to run your own checks before allowing it to initialize.

// Override the Initialize function
protected override bool Initialize()
{
    // Some code
}

// Check if input script is initialized
if (myGeneralInputScript.Initialized)
{
    // Some code
}

// Do something if initialization fails
protected override void OnInitializationFailed()
{
    // Some code
}

Input Update Conditions

If you want to run a General Input script only when certain conditions are met, you can add values to the Input Update Conditions list in the inspector. These are similar to Unity Events, and you can add boolean functions or getters from any script that must return True for the input to work.

Enable/Disable Input

You can enable or disable an input script at any time, or check if it is enabled:

// Enable input
myGeneralInputScript.EnableInput();

// Disable input
myGeneralInputScript.DisableInput();

// Check if the input is enabled
if (myGeneralInputScript.InputEnabled)
{
    // Some code
}

Adding Your Input Code

To add your input code to a General Input script, you can override the Input Update function, which is only called when the input script is initialized and enabled and the input update conditions are met.

// Override input
protected override void InputUpdate()
{
    // Add your input code
}

// Do something when input update fails (e.g. cancel a running operation)
protected override void OnInputUpdateFailed()
{
    // Do something
}

Last updated