Vehicle Component
VehicleComponent is a building block of NWH Vehicle Physics 2.
VehicleController is a collection of VehicleComponents, which includes VehicleModules, Effects and SoundComponents - both of which inherit from VehicleComponent.
State
Enabled / Disabled
VehicleComponentthat is enabled is updated.- Disabled components are not initialized until they get enabled for the first time.
- Disabling a
ManagerVehicleComponentsuch asSoundManager,EffectsManager,ModuleManagerorPowertrainalso disables the childVehicleComponents.
LOD Index
- If the component's
lodIndexvalue is lower thanvehicleController.activeLodIndexit will be enabled, otherwise it will be disabled. - Set
lodIndexto a value less than 0 to ignore LODs. - If adjusting LODs through inspector click on the currently active LOD to disable LOD system.
State Bar
Each VehicleComponent has a state bar which is visible in play mode:
This is where the state of the VehicleComponent can be checked and changed. Note that changing the state through state bar only affects runtime values and will revert after exiting play mode. The state bar is intended for previewing the current state and testing different values during run-time. For persistent state check StateSettings.
Using the State Bar
- Click on “On” button to turn the component on or off.
- Click on “Enabled” button to enable or disable the component.
- Click on any of the LOD numbers to set LOD. Click again on the same number to disable LODs. Component will be enabled if the current LOD number is green, and disabled if it is red. When LODs are active
Enabledbutton is greyed out as the LODs determine if the component will be enabled or disabled.
State Settings
- To prevent having to adjust the states of each
VehicleComponenton eachVehicleController, aScriptableObjectStateSettingswas introduced.
StateSettingsfor each vehicle can be assigned under VehicleController ⇒ Settings tab.
- More about
StateSettingson State Settings page.
Scripting
To change VehicleComponent state through scripting following can be done:
myVehicleComponent.LodIndex = -1; // IMPORTANT! Setting this to -1 disables the
// LODs which otherwise override the enabled/disabled setting.
myVehicleComponent.VC_Enable();
myVehicleComponent.VC_Disable();
- All the
VehicleComponentinitialization and update functions start with theVC_prefix to prevent confusion with Unity callbacks, e.g.VC_InitializeorVC_FixedUpdate.</wrap>