User Tools


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.
For class reference click here.

States

Each VehicleComponent can:

  • Be turned on or off.
  • Be enabled or disabled.
  • Have LOD set.
IsEnabled
  • VehicleComponent that is enabled is updated.
  • If the component will never be used isOn can be used instead.
  • Disabled components are not initialized until they get enabled for the first time.
Enabled VehicleComponent.
Disabled VehicleComponent.
LOD Index
  • If the component's lodIndex value is lower than vehicleController.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:
LOD system is inactive and the VehicleComponent will be active until manually disabled.
LOD system is active. VehicleComponent will be enabled while active LOD is 0 or 1 and disabled while active LOD is 2 or 3.
IsOn

VehicleComponents that have isOn set to false are disabled and can not be enabled by LODs.
Turning components off should be used for components that will never be used.

VehicleComponent turned off. Once it is off it can only be turned on manually. LODs are ignored when off.


State Diagram

Diagram below demonstrates how a VehicleComponent determines if it should be updated:

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 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 each VehicleController, a ScriptableObject StateSettings was introduced.
  • StateSettings for each vehicle can be assigned under VehicleController ⇒ Settings tab.
  • More about StateSettings on StateSettings page.

Scripting

To change VehicleComponent state through scripting following can be done:

myVehicleComponent.IsEnabled= myBoolValue;
myVehicleComponent.IsOn = myBoolValue;
myVehicleComponent.LodIndex = myIntValue;