# 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.Vehicles;

// 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](/universal-vehicle-combat/input-basics/general-input.md) for:

* Enabling/disabling input
* Adding input update conditions
* Adding your input code


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vsxgames.gitbook.io/universal-vehicle-combat/input-basics/vehicle-input.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
