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:
// Destroy a vehicle
// Restore a vehicle
// Check if the vehicle is destroyed
if (myVehicle.Destroyed)
// Some code
// Add a function to be called when the vehicle is destroyed
// Add a function to be called when the vehicle is restored

Get Vehicle Occupant

Sometimes you might want to know what game agent is controlling a vehicle.
// Get vehicle occupants
List<GameAgents> occupants = myVehicle.Occupants;
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.
Last modified 10mo ago
Copy link
On this page
Creating A Vehicle
Vehicle Classes
Destroying/Restoring Vehicles
Get Vehicle Occupant