Vehicle Component
VehicleComponent
is a building block of NWH Vehicle Physics 2.
VehicleController
is a collection of VehicleComponent
s, which includes VehicleModule
s, Effects
and SoundComponent
s - both of which inherit from VehicleComponent
.
State
Enabled / Disabled
VehicleComponent
that is enabled is updated.- Disabled components are not initialized until they get enabled for the first time.
- Disabling a
ManagerVehicleComponent
such asSoundManager
,EffectsManager
,ModuleManager
orPowertrain
also disables the childVehicleComponents
.
LOD Index
- If the component's
lodIndex
value is lower thanvehicleController.activeLodIndex
it will be enabled, otherwise it will be disabled. - Set
lodIndex
to 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
Enabled
button 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
VehicleComponent
on eachVehicleController
, aScriptableObject
StateSettings
was introduced.
StateSettings
for each vehicle can be assigned under VehicleController ⇒ Settings tab.
- More about
StateSettings
on 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
VehicleComponent
initialization and update functions start with theVC_
prefix to prevent confusion with Unity callbacks, e.g.VC_Initialize
orVC_FixedUpdate
.</wrap>