Vehicles in BeamNG are made using JBeam files for defining a physical skeleton using mass points (nodes) and flexible spring-damper connections (beams). The visual skin is defined using DAE files and is connected to this physical skeleton. It can be challenging and time-consuming for new users to create a vehicle using this bottom-up approach.
The Template Car Generator is a tool that helps users to get started quickly by creating simple vehicles based on high-level vehicle parameters, such as total mass, basic geometry like wheelbase, track width and height, as well as suspension type and body shape. The user can make multiple vehicle configurations (user input). These user inputs are used by the tool to automatically generate a set of JBeam and DAE files (output files) that meet the user-defined requirements. The generated output files are saved in the user’s mod directory and can directly be used in BeamNG.
The generated JBeam files are kept as simple as possible, so that more experienced users can also use them as a starting point to modify the vehicle further and adjust its physical behavior in detail.
The Template Car Generator is the parameterizable enhancement of the Template Car available since BeamNG.tech v0.36. You can still use this car if you don’t need parameter adjustments.
The Template Car Generator is shipped with BeamNGpy . Note that Python 3.9 or newer must be installed on your system. The simplest way to install BeamNGpy is by opening a terminal and running the following command:
pip install beamngpy
For more installation options, refer to the BeamNGpy documentation .
Make sure that you have started BeamNG.tech at least once before starting the application. Close BeamNG.tech if it is running.
It is recommended to create a Desktop shortcut to the application by running:
python -m beamngpy.tools.template_car --create-shortcut
Then you can launch the application by double-clicking on the shortcut on the Desktop. Note that this will only work if beamngpy is installed in the global Python environment.
Alternatively, you can always start the application by running:
python -m beamngpy.tools.template_car
This works in any Python environment.
After starting the application, a window like the one shown below will open.
Template Car Generator welcome screen
You can change general application settings by clicking on Settings in the lower left corner.
%LOCALAPPDATA%/BeamNG/TemplateCarGenerator/vehicles.By default those application settings are stored in the %LOCALAPPDATA%/BeamNG/TemplateCarGenerator/settings.json file. If you want to start the application using a different settings file, you can start it with python -m beamngpy.tools.template_car --settings-file path/to/settings.json.
On the settings screen you can also find a few convenience links to open the settings file, vehicle configurations folder and mods folder.
Use the section numbers (1–8) to follow along with the UI layout in the tool.
Click on Create vehicle to create a new vehicle. Enter the vehicle name in the popup screen and click on Create vehicle. This initial name will be used to generate the vehicle ID.
You can change the name of your vehicle here.
Configure vehicle structure and parameters:
Controls for:
Toggle these between:
Limitations:
When optimization is required, a log shows progress on the optimization loop, giving information on how many iterations have been done and how far away from the target the loop is currently at.
Spawns the car in Grid Small Pure in BeamNG for quick testing. Alternatively, you can also launch BeamNG yourself and select the vehicle in the Vehicle Selector.
The generated files are designed in a manner that are easy to modify for beginners. Some modification will be necessary to fine tune the suspension if the centre of gravity location has been moved or if the mass has changed significantly.
Removes the selected vehicle configuration from the sidebar and moves the corresponding JSON file to the trash bin.
The generation algorithm to generate the JBeam files has several scalar tuning factors that influence node mass and node mass distribution:
The user can set these factors directly when choosing Factor. In this case the factor is applied directly to the generation algorithm, but the outcome (actual vehicle mass and center of gravity) is not directly settable by the user.
If the user chooses Target, then then a physical value (in meters or kilograms) is entered and the generation algorithm is run iteratively, adjusting the scaling factors until the target value is reached. Note that BeamNG is launched during this process because the physics engine is needed to calculate the actual values of mass and center of gravity. For the center of gravity the vehicle is spawned and then settles to its equilibrium position before the actual value is measured.
Go to the Settings page and click on Open vehicles folder. Then you can duplicate a JSON file and rename it to the desired name. It will show up in the application and you can start modifying it.
Go to the Settings page and click on Open vehicles folder. Then you can rename the corresponding JSON file. Note that only A-Z, a-z, 0-9 and _ are allowed in the vehicle ID.
Read the BeamNGpy documentation of the Template Car Generator API for more information on how to use Python scripts to generate vehicles.
For example, the following script generates all template cars you have defined in the application:
"""Example script to generate all template cars."""
from beamngpy.tools.template_car import TemplateCarGenerator
generator = TemplateCarGenerator()
for vehicle_id in generator.get_vehicle_list():
vehicle = generator.get_vehicle(vehicle_id)
generator.generate(vehicle_id, vehicle)
print(f"Generated {vehicle_id}")
print("All vehicles generated.")
The JBeam files of the template car are designed to follow the following conventions:
fw1r and fw1l and the front axle centerpoint is the middle point between these two nodes.Note: For the center of gravity (COG) the actual equilibrium position of the front axle centerpoint is used as reference.
On Linux, %LOCALAPPDATA% is replaced by ~/.local/share.
If you get an error message like You must have either QT or GTK with Python extensions installed in order to use pywebview on Linux, please try one of the following:
pip install pywebview[qt]
or
pip install pywebview[gtk]
This should install the necessary dependencies.
Was this article helpful?