NWH Vehicle Physics 2 Documentation
Admin » NWH:VehiclePhysics2:VehicleComponent

Differences

This shows you the differences between two versions of the page.


Previous revision
—NWH:VehiclePhysics2:VehicleComponent [2023/05/16 16:08] (current) – [Scripting] nwhcoding
Line 1: Line 1:
 +====== 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 as ''SoundManager'', ''EffectsManager'', ''ModuleManager'' or ''Powertrain'' also disables the child ''VehicleComponents''.
 +
 +[{{ :NWH:VehiclePhysics2:pasted:20230504-183632.png?400|Enabled ''VehicleComponent''. }}]
 +
 +[{{ :NWH:VehiclePhysics2:pasted:20230504-183646.png?400|Disabled ''VehicleComponent''. }}]
 +
 +[{{ :NWH:VehiclePhysics2:pasted:20230504-183703.png?400|''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:
 +[{{ :NWH:VehiclePhysics2:pasted:20230504-184059.png?400|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.
 +[{{ :NWH:VehiclePhysics2:pasted:20230504-184009.png?400|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 [[NWH:VehiclePhysics2:StateSettings|State Settings]] page.
 +
 +==== Scripting ====
 +To change ''VehicleComponent'' state through scripting following can be done:
 +
 +<code>
 +myVehicleComponent.LodIndex = -1; // IMPORTANT! Setting this to -1 disables the 
 +                                  // LODs which otherwise override the enabled/disabled setting.
 +myVehicleComponent.VC_Enable();
 +myVehicleComponent.VC_Disable();
 +</code>
 +
 +  * 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>
NWH Vehicle Physics 2 Documentation

Table of Contents

  • About
  • Setup
  • Input
  • Vehicle Controller
  • Wheel Controller
  • NWH Common Scripts
  • Trailers
  • GUI
  • Multiplayer
  • Render Pipelines
  • Add-ons
  • FAQ
  • Troubleshooting
  • Demos
  • Changelog
  • Upgrade Notes
  • Support