Variables

Variables

From BeamNG

Revision as of 10:31, 19 December 2015 by Gabester (Talk | contribs) (Created page with "== Overview == Variables are a new feature introduced in 0.5.0.0. They allow you to change any numeric value in a .jbeam dynamically with the tuning menu in-game. == Example...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Overview

Variables are a new feature introduced in 0.5.0.0. They allow you to change any numeric value in a .jbeam dynamically with the tuning menu in-game.

Example Section

    "variables": [
        ["name", "type", "default", "min", "max", "step", "title", "description"]
        ["$camber_RR", "range", 0.997, 0.95, 1.05, 0.001, "Rear Right Camber", "Rear right camber"]
        ["$camber_RL", "range", 0.997, 0.95, 1.05, 0.001, "Rear Left Camber", "Rear left camber"]
        ["$toe_RR", "range", 0.998, 0.95, 1.05, 0.001, "Rear Right Toe", "Rear right toe"]
        ["$toe_RL", "range", 0.998, 0.95, 1.05, 0.001, "Rear Left Toe", "Rear left toe"]
        ["$trackwidth_R", "range", 0.26, 0.26, 0.29, 0.005, "Rear Track Width", "Rear track width"]
    ],

Most of the options are pretty self-explanatory. The name of the variable must start with the $ character.

Usage Cases

Variables can be used for literally any number in a .jbeam, including node position, weight, spring, damp, deform, precompression, or whatever else you can think of. Simply replace the number with the name of the variable (don't forget quotes).

This is an example of using variables to control camber, in this case the upper arm of the Covet's rear suspension. By precompressing the beam, we change the length of it, thus angling the wheel in or out due to the design of the suspension.

          //camber adjust
          ["rx3r","rh3r"{"beamPrecompression":"$camber_RR"}],
          ["rx3l","rh3l"{"beamPrecompression":"$camber_RL"}],

An interesting possible use for variables would be to position a part, such as cargo on a roof rack, by replacing the x and y nodeOffset coordinates with variables. You could then position the part in-game anywhere within the predefined range you've set. This concept is used for adjustable track width on all of the cars. The x axis nodeOffset for the wheels is set by the variable.