🎨
UVC
  • Introduction
  • Installation
    • Installing in New Project
    • Installing in Existing Project - SCK
    • Installing in Existing Project - MCK
  • Space Combat Kit Tour
  • Mech Combat Kit Tour
  • Player Setup
  • Vehicle Framework
    • Game Agents
    • Vehicles
    • Modules
      • Module Mounts
      • Modules
      • Module Types
      • Module Attachments
      • Display Module On UI
      • Module Managers
  • Input
    • General Input
    • Vehicle Input
    • Rewired Integration
  • Player/AI
  • Spaceships
    • Speed UI
    • Space Fighters
    • Capital Ships
  • Mechs
    • Speed UI
  • Vehicle Control Animations
  • Character Enter/Exit
  • Camera
    • Camera Setup
    • Vehicle Setup
    • Secondary Cameras
    • Death Camera
  • Weapons
    • Framework
      • Triggerables System
      • Weapon System
    • Vehicle Setup
      • Vehicle Weapons
      • Cursor Aiming
    • Projectile Weapons
    • Beam Weapons
    • Missile Weapons
    • Resource Handling (Ammo/Heat)
    • Turrets
    • HUD Weapon Info
    • Health Modifier Volumes
  • Radar
    • Radar Setup
    • Target Setup
    • Target Selectors
    • Trackable Types
    • Improving Radar Performance
    • Target Notification
    • Radar Audio
  • Health
    • Health Framework
      • Health
      • Damageable
      • Damage Receiver
      • Health Modifier
      • Health Types
      • Health Modifier Types
      • Surface Types
    • Vehicle Setup
    • Damageable Object Setup
    • Detonators
    • Health Recharge
    • Health UI
    • Energy Shield
    • Damageable Module Linkers
  • HUD
    • HUD Basics
    • HUD Manager Setup
    • Custom HUD Components
    • HUD Module Display
    • Camera View Management
    • HUD Cursor / Reticle
    • Weapon UI
    • Resource Container UI
    • 2D Radar
    • 3D Radar
    • Target Boxes
    • Target Holograms
    • Minimaps
    • HUD Distance Lookup
  • Loadout
  • AI - Space Combat Kit
    • AI Setup
    • AI Spaceship Behaviours
  • AI - Mech Combat Kit
  • Game States
  • Teams
  • Floating Origin
  • Object Pooling
  • Menus
    • Creating Menus
    • Button Controllers
  • Rumbles
  • Rigidbody Characters [WIP]
  • Utilities [WIP]
    • Object Triggers
    • Shadow Caster Doubles
    • Gimbals
    • Game State Post Process Enabler
  • Objectives
  • Resources System
    • Resource Containers
    • Resource Handlers
    • Resource Container Triggers
    • Module/Vehicle Resource Usage
    • UI
  • Cutscenes
  • URP Upgrading
Powered by GitBook
On this page
  • Creating A Vehicle
  • Destroying/Restoring Vehicles
  • Vehicle Occupant
  • Module Mounts
  • Vehicle Classes

Was this helpful?

  1. Vehicle Framework

Vehicles

A Vehicle component represents an object that the player can control to move around in the game world.

Creating A Vehicle

To begin creating a new vehicle of any kind, create a new game object in the scene and add a Vehicle component.

Destroying/Restoring Vehicles

Like 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
myVehicle.Destroy();

// Restore a vehicle
myVehicle.Restore();

// Check if the vehicle is destroyed
if (myVehicle.Destroyed)
{
    // Some code
}

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 component has been scripted to allow for multiple occupants, but currently the kits only support one occupant per vehicle. So the list will normally have one member when a vehicle is occupied, and be empty when it is not.

Sometimes you might want to do something different when a player enters the vehicle vs when an AI enters the vehicle, or when the occupant exits a vehicle. You will find Unity Events in the inspector you can add functions to that you wish to be called when any of these events occur.

Module Mounts

To get all the module mounts on a vehicle, or add/remove a module mount, use the following code:

// Get a list of all the module mounts on the vehicle
List<ModuleMount> moduleMounts = vehicle.ModuleMounts;

// Add a module mount to the vehicle
myVehicle.AddModuleMount(someModuleMount);

// Remove a module mount from the vehicle
myVehicle.RemoveModuleMount(someModuleMount);

Vehicle Classes

The Vehicle Class (which is a Scriptable Object) provides a way to differentiate between vehicles, for example for running specific input scripts or camera controllers.

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.

PreviousGame AgentsNextModules

Last updated 2 years ago

Was this helpful?