Vehicles
All the kits in the Universal Vehicle Combat series (including the Space Combat Kit and the Mech Combat Kit) share a common vehicle framework that makes it easy to integrate different vehicles into your game.
A vehicle is represented by the Vehicle component, which represents something that the player or AI can take control of to move around and interact in the game world.

Creating A Vehicle

To create a new vehicle, simply create a new game object and add a Vehicle component.
A Vehicle component can represent many different kinds of vehicles.
As you can see, the Vehicle component has many events that you can add functions to if you want them to be called when certain events occur.

Vehicle Classes

The 'Vehicle Class' property enables differentiating between different kinds of vehicles, for example for running specific input scripts or camera controllers.
Vehicle Classes are Scriptable Objects.
To create a new Vehicle Class, right click in the Project view and select Create > VSX > Vehicle Class.
This will create a new Vehicle Class object in your Assets folder, which you can rename.
To assign a Vehicle Class to a Vehicle, simply drag the Vehicle Class object you created into the 'Vehicle Class' field in the inspector of the Vehicle component.

Destroying/Restoring Vehicles

Similarly to Game Agents, vehicles can be destroyed or restored during gameplay. Here is some code to help you understand how you can do this:
1
// Destroy a vehicle
2
myVehicle.Destroy();
3
​
4
// Restore a vehicle
5
myVehicle.Restore();
6
​
7
// Check if the vehicle is destroyed
8
if (myVehicle.Destroyed)
9
{
10
// Some code
11
}
12
​
13
// Add a function to be called when the vehicle is destroyed
14
myVehicle.onDestroyed.AddListener(someFunction);
15
​
16
// Add a function to be called when the vehicle is restored
17
myVehicle.onRestored.AddListener(someFunction);
Copied!

Get Vehicle Occupant

Sometimes you might want to know what game agent is controlling a vehicle.
1
// Get vehicle occupants
2
List<GameAgents> occupants = myVehicle.Occupants;
Copied!
Note that the vehicle has been scripted to allow for multiple occupants, but currently the UVC kits only support one occupant per vehicle. So the list will normally have one member when a vehicle is occupied.