Skip to content
Dan Royer edited this page Jun 11, 2023 · 4 revisions

image

Create a vehicle (easy way)

The vehicle factory is available from Demos > create vehicle.

  • Type: choose from one of the available types.
  • Wheel radius: radius of cylinder.
  • Wheel thickness: length of the cylinder.
  • body length: length on X. Also sets the wheel base, which affects turn radius of motorbikes.
  • body width: length on Y. Also sets the distance between wheels, which affects turn radius of cars.
  • body height: length on Z.
  • body radius: only for omni vehicles.
  • ground clearance: Z distance from bottom of wheels to bottom of vehicle body.
  • Add: creates a vehicle of the

Avialable types

  • front wheel drive (FWD): basic car
  • rear-wheel drive (RWD): basic car, alternate motors.
  • motorcycle: two wheel vehicle, front steering, rear motor.
  • mecanum: 4 independently motorized mecanum wheels. unique differential steering. can strafe.
  • omni: 3 indepdendently motorized wheels. unique differential steering. can strafe.
  • tank: 2 indepdendently motorized wheels. unique differential steering.
  • 4 wheel chassis: basic car body, wheels, no motor.

Please note

  • All dimensions in centimeters, seconds, and kilograms.
  • All cars point forward on their X axis and up on their Z axis.
  • Unless noted, vehicles cannot strafe.
  • Vehicles were introduced in 2.6.4.

Create a vehicle (hard way)

  1. Create an entity called "car". Add a CarComponent to car.
  2. Create an entity called "mesh" under car. Add a Shape to the body and position it.
  3. for each wheel,
  • create an entity called "suspension" under car.
  • create an entity called "wheel" under suspension.
  • create an entity called "mesh" under wheel.
  • Add a Shape (probably Cylinder) to the wheel mesh and position/rotate it. The mesh will rotate around the Z axis.
  • add a WheelComponent to wheel.
  • Set the diameter and width of the wheel in WheelComponent.
  1. Add each wheel to the list of wheels in CarComponent.

Note step 3 can be done once and then copy/pasted to save time.

Motors

  1. For vehicles with one motor, add an entity called "motor" under car and add a DCMotorComponent to motor.
  2. For vehicles with one motor per wheel, add DCMotorComponent to each wheel entity.
  3. In each WheelComponent, set the "drive" to the motor entity. This tells the vehicle system which wheel is driven by which motor.
  4. In each DCMotorComponent, add all the wheel meshes driven by this motor to the list of connections.

You can then select each motor to adjust their RPM/torque curves.

Steering

  1. Add ServoMotorComponent to the suspension of each steer-able wheel.
  2. In each WheelComponent, set the "steer" to the suspension. This tells the vehicle system which which servo drives this wheel.
  3. In each ServoMotorComponent, add the wheel entity to the list of connections.

You can then select each servo motor to adjust their RPM/torque curves and PID response.

Driving

image

  1. Select the root of a vehicle.
  2. Locate CarComponent steering values.
  • Desired turn will immediately affect tank, omni, and mecanum vehicles.
  • Desired forward will immediately affect all vehicles. Turn will only affect FWD and RWD when the vehicle is moving.
  • Desired strafe will immediately affect omni, and mecanum vehicles.