This page has been translated automatically.
编程
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Drivers

A car's logic (a "Car" class) is controlled only by the car's physics and signals. It also has all functionality necessery to drive a car. Any car (user-controlled or AI-controlled) needs a "driver" to follow road regulations.

For this purpose, there is a special base class called "Driver". Each car should have an instance of this class to be controlled.

A "Driver" class implements the following:

  • Search for the road and road's direction.
  • Evaluation of the amount of lanes.
  • Recognition of the lane, along which a car is moving.

Crossroads logic can also influence the "Driver" class. When a driver enters the crossroads (no matter if it is a user-controlled or AI-controlled driver), it receives the crossroad driving spline and driving priority value. A spline is defined the following ways:

  • For user-controlled cars: based on activated turn signals.
  • For AI-controlled cars: chosen randomly.

All of the drivers make decisions for further movements based on these splines and driving priority values. Thus, "drivers" act like they do on real roads: they look around, look at other cars and their turn signals, look at stop signals, and look at crosswalks and let pedestrians pass by.

Control Keys

To control a car with a keyboard use the following keys:

Common

  • A / Left Arrow - turn left
  • D / Right Arrow - turn right
  • Space - brake
  • Shift - hand-brake
  • H - turn the headlights on/off
  • Q / Home - turn the left-turn signal on/off
  • E / PgUp - turn the right-turn signal on/off

Automatic Gearbox

  • W / Up Arrow - gas if moving forward (brake if moving backward)
  • S / Down Arrow - brake if moving forward (gas if moving backward)

Manual Gearbox

  • W / Up Arrow - gas
  • S / Down Arrow - brake
  • J - lower the gear
  • K - increase the gear

Other

  • F - enable the free-flying camera
  • G - enable the player camera
Notice
Joystick control is also supported. Check the driver_player.h file to see how its logic is implemented.
Last update: 2017-07-03
Build: ()