🎨
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
  • Setting Up The Character
  • Setting Up The Vehicle
  • Setting Up The Game Agent
  • Enter/Exit Prompts
  • Putting It Together
  • Starting Inside Vehicle
  • Camera Control

Was this helpful?

Character Enter/Exit

PreviousVehicle Control AnimationsNextCamera

Last updated 8 months ago

Was this helpful?

During the game, you may have a character that you wish to enter or exit a vehicle with by physically approaching and interacting with the vehicle. The following sections show you how to do this.

To enter/exit a vehicle without physically interacting with it (in code) see .

Setting Up The Character

To begin, set up your character as a vehicle. This might sound strange, but a character is simply another representation for what the player is controlling.

  1. Add a Vehicle component

  2. Add a Rigidbody component (may be kinematic or not)

  3. Add a Vehicle Enter Exit Manager component

  4. Make sure the character has a collider of some kind (may be a Character Controller)

Setting Up The Vehicle

Next, set up the vehicle:

  1. Make sure it has a Vehicle component

  2. Make sure it has a Rigidbody component (kinematic or not)

  3. Add a Vehicle Enter Exit Manager component

  4. Add a trigger collider, positioned where the character must be to enter the vehicle, and drag it into the Enter Exit Collider field in the inspector of the Vehicle Enter Exit Manager component.

  5. Add a new game object somewhere in the vehicle's hierarchy to represent where the character should be spawned when exiting the vehicle, and drag it into the Spawn Point variable in the inspector of the Vehicle Enter Exit Manager component.

Note that for spaceships, you can use the Ship Enter Exit Manager component instead of the Vehicle Enter Exit Manager component, as it comes with functionality for preventing enter/exit when she ship is not landed.

Setting Up The Game Agent

Add a Player Input_Input System_Enter Exit Controls component somewhere in the hierarchy of the Game Agent you want to be able to switch vehicles.

To rebind the controls, go to the project tab and double click the General Input Asset to open up the Input System editor. By default, the control used for entering and exiting is the General Controls > Use control.

Enter/Exit Prompts

To set up a text prompt for entering/exiting:

  1. Set up a text component somewhere in the scene or as part of the character's HUD (can be UGUI or TMPro).

  2. If you're using TMPro, add a UVCText_TMProUGUI component to the text object OR if you're using UGUI, add a UVCText_UGUI component to the text object.

  3. Drag the text object into the 'Prompt Text' field of the Vehicle Enter Exit Manager components on both the character and the vehicle.

Now you should get a prompt when you can enter or exit a vehicle.

To customize the prompts:

  1. Go to the PlayerInput_InputSystem_EnterExitControls component you set up earlier.

  2. Customize the enter/exit prompts.

To make sure that the prompts always refer to the control bindings you have set up, be sure to refer to the controls with {control}. Anywhere this appears in a prompt, it will be replaced at runtime with the correct control reference.

Putting It Together

Now, to be able to enter a vehicle, the Game Agent must be controlling the character vehicle you just set up, so drag the character vehicle into the Starting Vehicle field in the inspector of the Game Agent component.

Now run the scene.

When the character enters the trigger collider you set up on the vehicle, you can enter the vehicle by pressing the relevant input (by default, the F key).

If you want the player to start off in the vehicle (not the character) but to be able to exit to the character, drag the character vehicle into the Starting Child Vehicle field in the inspector of the Vehicle Enter Exit Manager component on the vehicle.

Starting Inside Vehicle

If the player starts off in a vehicle other than the character, but you still want them to be able to exit to the character during gameplay, make sure to go to whatever vehicle the player starts off in, go to its Vehicle Enter Exit Manager component, and set Starting Child Vehicle to the character.

Camera Control

If you're using a third party character controller (or your own) you probably want to switch off the character's camera controller when the character enters the vehicle.

You can easily do this by going to the character's Vehicle Enter Exit Manager and using the 'On Entered Parent' event to call a function to disable your camera controller, and the 'On Exited Parent' event to enable it again.

If you don't want to use the camera system provided in the kit for following your character, be sure not to add a Camera Target to the character, and the vehicle camera will simply do nothing and become passive when the player switches to the character.

this section
Video tutorial covering entering/exiting vehicles with a character.