Vehicle Input

Vehicle input is input that is run for a specific vehicle, for example a spaceship controller script. Vehicle input scripts extend the General Input base class, and must be placed in the hierarchy of a Game Agent.

A Game Agent gathers and stores all the Vehicle Input scripts in its hierarchy when the scene starts, and attempts to initialize them when it enters a new vehicle.

Creating A Vehicle Input Script

To create your own Vehicle Input script, create a new script that extends the Vehicle Input base class:

using VSX.UniversalVehicleCombat;

// Custom vehicle input script 
public class MyVehicleInput : VehicleInput {}

Initialization

When a Vehicle Input script is initialized, it means it has access to all the components on the vehicle that it needs to control, and is ready to run.

Vehicle Input scripts are not initialized by default. You must override the Initialize function in your own scripts to run your own checks on the vehicle that the Game Agent is entering, and only return True if the script is ready to run.

// Override the Initialize function
protected override bool Initialize(Vehicle vehicle)
{
    // Check that the vehicle is compatible with the input
}

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

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

The rest of the General Input script functionality applies to the Vehicle Input script as well, see this section for:

  • Enabling/disabling input

  • Adding input update conditions

  • Adding your input code

Last updated