Pack Making JSON Vehicles - DonBruce64/MinecraftTransportSimulator GitHub Wiki
Vehicles are the most complex area of the entire JSON system and are where you'll be spending the bulk of your time. As the vehicle JSON defines positions that relate to your model, it is important to ensure that your model is correctly scaled, positioned, and oriented BEFORE making the JSON file. If you have to re-do your model, you also will have to re-do JSON work, and that's extra work you don't want to do.
To ensure your vehicle's model is correct you can simply replace any OBJ model in a pack with your model. This will cause MTS to load that model instead, allowing you to verify that the model is correct before you go to the work of making a JSON for it. Once that is done, you're ready to tackle the JSON file. JSON files can be rather long, so expect a lot of sub-sections here.
Inherited JSON
Vehicles inherit the following core JSON sections:
Motorized
This section is for all vehicles and defines things like fuel capacity and where to put instruments and controls.
Properties that are marked with * can be modified using variableModifiers, for more advanced functionality.
- isAircraft – If this is true, then MTS will consider this vehicle an aircraft and have it use the aircraft control system. Has no other effect besides this.
- isBlimp – If this is true, then MTS will consider this vehicle a blimp and have it use the blimp control system. This modifies how engines reverse on this vehicle; blimps reverse the gears in their engines rather than invert the propeller pitch, so the signal needs to be different. This does not have to be combined with the isAircraft flag, but it is recommended to do so for actual blimps.
- isTrailer – If set to true, this vehicle will attempt to get and use the brake and electricity states of any vehicle that is towing it, it also uses any hookupVariables you have defined. Useful for trailers where you want the lights to come on with the vehicle, but not towed cars where you want them to stay off.
- hasThrustVectoring - Set this to true if you want the vehicle to have thrust vectoring. False means only yaw-vectoring will occur for things like engine out situations.
- hasOpenTop – Tells MTS that this vehicle does not have a roof. This is used only for the SoundSystem. If the vehicle has an open top, then both exterior and interior sounds will play at full volume, no matter the player position and camera setting. If the vehicle does not have an open top, then exterior sounds from OTHER sources than the vehicle will be quieter inside the vehicle, and exterior sounds on the vehicle itself will not play when inside the vehicle. Being "inside" is considered to be in first-person mode and not running a custom camera.
- hasAutopilot – What this does depends on the vehicle. If the vehicle is a car, this enables cruise control. If this is on an aircraft, it will hold altitude and roll. If this is on a helicopter or VTOL craft, it will cause it to auto-hover and stay in place.
- hasRadioNav – If set, this vehicle will be able to select and connect to beacons for directional wayfinding.
- hasSkidSteer – Set this to true if you want the vehicle to have skidSteer functionality. This allows the vehicle to turn in-place when stopped in neutral. This will also automatically invert the rotation of the wheels and treads to match the steering orientation, so no need to mess with JSON bits. Do keep in mind, however, that variables tied to the driveshaft won't work, as these use the engine's current gear, which will be 0!
- hasPermanentSkidSteer - Like hasSkidSteer, but in this case it's always active. Used for things that don't have a wheelbase, like mechs and hovercraft.
- hasIncrementalThrottle - Set this to true if you want the vehicle to have incremental throttle. This is only active for vehicles that are not aircraft, and will give the vehicle an aircraft-like throttle that increments in 1/100 units when the gas is pressed, and decrements in 1/100 units when the brake is pressed. Mainly for boats and other constant-throttle vehicles.
- hasSingleEngineControl - Set this to true if you want only one engine control button to control all engines on the panel. Useful if you have multiple engines in a vehicle, but want them all to start at the same time.
- hasRunningLights – Set this to true if the vehicle has these lights. This will make the respective switch apper in the panel.
- hasHeadlights – Set this to true if the vehicle has these lights. This will make the respective switch apper in the panel.
- hasTurnSignals – Set this to true if the vehicle has these lights. This will make the respective switch apper in the panel.
- hasNavLights – Set this to true if the vehicle has these lights. This will make the respective switch apper in the panel.
- hasStrobeLights – Set this to true if the vehicle has these lights. This will make the respective switch apper in the panel.
- hasTaxiLights – Set this to true if the vehicle has these lights. This will make the respective switch apper in the panel.
- hasLandingLights – Set this to true if the vehicle has these lights. This will make the respective switch apper in the panel.
- halfHUDOnly - If this is true, the HUD will be always rendered as a half HUD. Useful if you have a smaller HUD with nothing below the half-height.
- fullHUDOnly - If this is true, the HUD will be always rendered as a full HUD. Useful if you have specific large instruments.
- overrideAutoStart - If this is true, and auto engine start is true, this vehicle will behave as if auto engine start is false.
- steeringForceIgnoresSpeed - Set this to true if you want vehicles to ignore speed, and instead call from steeringForceFactor for their current steering force. Otherwise by default, vehicles will gradually lose their ability to steer as they gain speed.
- emptyMass – The mass of this vehicle, when empty, in kg. Note that fuel, cargo, players, and player inventories all count as weight, so this mass will not be the mass of the vehicle during normal operation. Not too important in cars, but in aircraft this value should be as close to the real-life value as possible to avoid physics issues.
- fuelCapacity – The fuel capacity of this vehicle, in mb.
- defaultFuelQty – If this is set, this vehicle will come pre-fueled with the specified fuel amount. Note that an engine must be present for MTS to know what type of fuel is required, so make sure you set one via a defaultPart in a part slot.
- batteryCapacity* - The maximum voltage (or capacity) of this vehicle's battery, accounting for slight overvoltage. Does not affect 'electric'-type motors, only the electrical system for starters and lights. Defaults to 14 if not set, since vehicles will be spawned with 85.71% of their maximum battery charge, meaning they will spawn with their battery charged up to 12V.
- steeringForceFactor* – The amount of steering force output for cars, based either on current speed or as a whole, dependent on steeringForceIgnoresSpeed for choosing between such behavior. By default a value of 0 results in default MTS steering forces, while 1 allows full steering force at any speed. However if steeringForceIgnoresSpeed is set to true then 0 will result in no steering force at any speed, with 1 otherwise resulting in the same handling.
- overSteer* – Dictates the amount of oversteer force a vehicle experiences when skidding, best used with little to no understeer for RWD applications as oversteer causes a vehicles "tail" to try and whip out from it.
- underSteer* – Dictates the amount of understeer force a vehicle experiences when skidding, best used with little to no oversteer for FWD applications as understeer means a vehicle is failing to make a turn, instead continuing to move forwards.
- overSteerAccel – Used similarly to overSteer to control the exact rate of skidding during extreme acceleration. It is advised to use variableModifiers for this instead as they offer more granular control if needed.
- overSteerDecel – Same as above but for extreme deceleration.
- axleRatio* – The gear ratio present for the axle of this vehicle. This is a constant, vehicle-specific ratio that will be multiplied with the gear ratio of the currently-selected gear of the engine to determine the rotation of the wheels. A good many cars have a 3.55 ratio, but other of course are possible. All depends on how much power you expect your engine to have, and how fast you want your car to go. Note that this parameter is required if you want your engine to drive wheels.
- gravityFactor* – The factor for how gravity is multiplied on this vehicle. 1.0 is default. Planes are unaffected by the mtsconfig value and can only be manipulated with it being defined in this section and thru VMs.
- brakingFactor* – The factor for how effective the brakes are on this vehicle. 1.0 is default, with higher values making for more effective brakes. Note that this doesn't affect braking in bad weather, with flat tires, or missing wheels, as should be obvious.
- maxTiltAngle – The angle which this vehicle will try to tilt to at max turning. Note that the vehicle may not reach this angle if it isn't going fast enough. Designed for bikes and boats that are mainly designed to stay on flat surfaces. Do not use on three-to-four wheeled vehicles like cars that have natural roll, as this will block them from doing just that.
- flapSpeed - How fast flaps deploy, in degrees/tick. Only used if the vehicle has flap notches set.
- dragCoefficient* – How areodynamic this vehicle is. Defaults to 0.03 for aircraft, and 2.0 for cars, but can be adjusted to other values. For things like cars this will make a significant difference in your high-speed performance. So do some research before you slap some random value in here! If you don't set this parameter, one will be automatically generated. Planes and non-planes have a different formula, as planes are more areodynamic than most other vehicles.
- tailDistance – The distance from the center of rotation of the model, to the center point of the tail, in the Z-axis, in meters. This essentially tells MTS where the rudder and elevators are located so it knows where to apply the forces they create.
- wingSpan* – The wingspan of this vehicle, or distance between the wingtips, in meters.
- wingArea* – The surface area of the wings of this vehicle, in square meters. Make sure not to include the fuselage between the wings as that doesn't generate lift! Note: Value is for a single wing. It is multiplied by 2 when calculating physics.
- aileronArea* – Similar to wingArea, but for the ailerons. Units are square meters.
- elevatorArea* – Similar to wingArea, but for the elevators. Units are square meters.
- rudderArea* – Similar to wingArea, but for the rudder. Units are square meters.
- crossSectionalArea – The cross-sectional area of this vehicle, at its thickest point. This is used to calculate yaw-based drag on vehicles. Auto-calculated if left blank, and not required for most vehicles (and has no effect on winged vehicles), but is pretty much required on blimps to ensure they generate enough dynamic drag to allow the rudder to change their direction.
- ballastVolume* – How big the ballast volume is for this vehicle. An average value is 1/1000 of the empty weight. Set higher or lower to your liking. This will let your vehicle vertically ascend without power. Useful for blimps and janky elevators.
- waterBallastFactor* – The factor of which to apply ballast for water operations. 0 is no change, 0.5 makes them fall half speed, 1.0 makes vehicles neither float nor sink, and anything higher makes them float up. Only applied when the vehicle is in water.
- crashSpeedMin - The speed at which 0% damage will be applied during crashes. Crash damage values are optional and a default will be used if these are missing.
- crashSpeedMax - The speed at which 100% damage will be applied. Leave at 0 to disable crash damage.
- crashSpeedDestroyed - The speed at which the vehicle will blow up and be destroyed. Needs to be higher than crashSpeedMax.
- gearSequenceDuration – This parameter is optional. If included, and set to anything besides 0, the vehicle will be considered to have landing gear, with the transition between up and down having the passed-in duration.
- litVariable - When this variable is 1, the vehicle will be considered to be 'lit'. This makes text and instruments light up, provided there's enough battery power to do so.
- hudTexture – If this is present, MTS will render this texture for the HUD rather than the default texture. Make sure to include a _lit variant otherwise things will look weird!
- panelTexture – Same as hudTexture, but for the panel.
- panelTextColor – The Color for the text in the panel that renders below components. If this is not included MTS will default to white.
- panelLitTextColor – Same as panelTextColor, but for the text when the vehicle's lights are on.
- flapNotches - A listing of notches for flap deployment. These will be used to determine the requested flap setting for vehicles that have them. Only functional for vehicles where isAircraft is set to true. Both 0 and the highest notch should be included.
- hookupVariables - A listing of variables that will be checked from the towing vehicle rather than this one if this vehicle is a trailer and connected. Used by trailers to get the states of their towing vehicles for light and door animations.