NWH Vehicle Physics 2 Documentation
Action disabled: source
Docs » NWH:VehiclePhysics2:VehicleComponent

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

  • VehicleComponent that is enabled is updated.
  • Disabled components are not initialized until they get enabled for the first time.
  • Disabling a ManagerVehicleComponent such as SoundManager, EffectsManager, ModuleManager or Powertrain also disables the child VehicleComponents.
Enabled VehicleComponent.
Disabled VehicleComponent.
VehicleComponent Enabled/Disabled is controlled by LOD.

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.

State Bar

Each VehicleComponent has a state bar which is visible in play mode:

State Bar of the SkidmarkManager.

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 bar with the LODs enabled.

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 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 the VC_ prefix to prevent confusion with Unity callbacks, e.g. VC_Initialize or VC_FixedUpdate.</wrap>
Previous Next

NWH Vehicle Physics 2 Documentation

Table of Contents

Table of Contents

  • Vehicle Component
    • State
      • Enabled / Disabled
      • LOD Index
      • State Bar
      • State Settings
      • Scripting
  • About
  • Setup
  • Input
  • Vehicle Controller
  • Wheel Controller
  • NWH Common Scripts
  • Trailers
  • GUI
  • Multiplayer
  • Render Pipelines
  • Add-ons
  • FAQ
  • Troubleshooting
  • Demos
  • Changelog
  • Upgrade Notes
  • Support