Vehicles Input

Overview

Navigate terrain maps with “drivable” vehicles through basic keyboard or gamepad input. Cycle multiple camera angles in and around the vehicle for observation of variables in the environment that affect physics of the vehicles, such as the suspension’s handling over “bump” objects. An overlay displays vehicle motion statistics in real-time.   

Page Contents

Purpose

Navigate terrain maps with “drivable” vehicles through basic keyboard or gamepad input. Cycle multiple camera angles in and around the vehicle for observation of variables in the environment that affect physics of the vehicles, such as the suspension’s handling over “bump” objects. An overlay displays vehicle motion statistics in real-time.   

How to Use

Vehicle navigation controls vary by input device:

  1. Keyboard:
    1. Accelerate/Reverse – W/S or Up/Down arrow keys
    2. Turn left/right – A/D or Left/Right arrow keys
  2. Gamepad/Controller:
    1. Accelerate/Reverse – Up/Down on left analog thumb-stick 
    2. Turn left/right – Left/Right arrow key on left analog  thumb-stick 

Switch camera angles by pressing the C key. Note, when at first-person view in the driver position, use mouse-look to change the camera orientation. 

Exit and enter the vehicle by toggling the T key.

Enable the handbrake by holding the Space bar. 

Pause the game by toggling the P key.

Note, the R key will call a function that attempts to reload the scene. This currently fails in the example scene. 

The corner overlay displays the following values:

  • Gear
  • Velocity (km/h)
  • Velocity (mp/h)
  • Handbrake
  • Pause

Scene Location & Name

Assets/Ride/Examples/Vehicles/ExampleVehiclesInput.unity

Setup Requirements 

Utilize vehicle controls and first-person camera API for your scene by adding the following prefabs, which their respective scripts:

  • Assets/Ride_Dependencies/MSVehicleSystem(FreeVersion)/Prefabs/Control.prefab
  • Assets/Ride_Dependencies/MSVehicleSystem(FreeVersion)/Prefabs/MSFPSController.prefab
  • Assets/Ride_Art/Art/Characters/MiddleEast/Legacy/Resources/RideEntities/VehicleInputControllerPrefab.prefab (VehHmvM111402)

Note, the VehicleInputControllerPrefab contains the humvee model from Bravemind. Reference setup of this prefab when adding your own vehicle model to a custom prefab. Add the following script to the root of your prefab to enable vehicle control:

Assets/Ride_Dependencies/MSVehicleSystem(FreeVersion)/Scripts/MSVehicleControllerFree.cs

The example scene contains an OWT terrain map, collision mesh, and start point, represented by objects TerrainLoader, RazishNavmesh and TerrainCenter. 

Note, the Scenario object is for testing purposes only, and belongs to the MSVehicleSystem(FreeVersion) 3rd party package.  

Control Prefab w/MSSceneControllerFree Script

First, add the Control prefab to your scene and in the Vehicles > Element 0 field, add your vehicle prefab. Next, in the Player field, add the MSFPSController prefab once instanced in your scene.

This prefab also contains the necessary Canvas child prefab. 

MSFPSController Prefab and MSFPSController Script

Next, import the MSFPSController prefab into your scene for first-person controls of your avatar by way of the MSFPSController script. This prefab also contains the necessary Camera and Canvas child prefabs.

Remember to add this vehicle prefab in the Vehicles > Element 0 field of the Control prefab instanced in your scene.

VehHmvM111402Prefab Prefab and MSVehicleControllerFree Script

Next, import the VehHmvM111402Prefab prefab into your scene as the vehicle to be controlled by way of the MSVehicleControllerFree script.

This “game-ready” prefab contains all the necessary objects, including model, cameras, colliders, etc.