NWH Vehicle Physics 2 Documentation
Docs » NWH:Common:CoM:VariableCenterOfMass

Variable Center of Mass

VariableCenterOfMass inspector.

This is a common script shared between all the vehicle focused NWH assets.
Since Unity 2022 this script is no longer needed to adjust center of mass or inertia from the inspector as those settings are now exposed through Rigidbody inspector.

  • Adds an option to adjust the center of mass and inertia tensor of the vehicle Rigidbody through the inspector. In Unity 2023 and newer this can be done through the Rigidbody inspector.
  • It also has a MassAffector feature where the mass, center of mass and inertia can be impacted by MassAffectors attached to the vehicle. This can be a fuel tank, a piece of cargo, a player, etc. MassAffectors, despite affecting the Rigidbody properties, are not Rigidbodies. This allows for things like cargo to affect the vehicle, without having the overhead of Rigidbody collisions/joints/etc.
  • VariableCenterOfMass is designed to give users more control over the Rigidbody which is usually needed for use with vehicles. This is because Unity assumes all objects/colliders have uniform density and therefore calculates the center of mass and inertia using that assumption. This script allows for tweaking of both of these values to better fit the specific vehicle. Center of mass and inertia tensor, besides mass, have the biggest effect on vehicle handling.
  • The variable part of the name comes from the ability of the script to adjust the mentioned parameters at runtime through IMassAffectors. There are components attached to different parts of the vehicle that affect the vehicle mass, the center of mass, and inertia but are not Rigidbodies by themselves. Examples of this would be fuel tanks, passengers, cargo, etc.
Usage
  • Attach the MassAffector (or any script inheriting from IMassAffector to a GameObject that is a child of the vehicle.
  • Tick Use Mass Affectors on the VariableCenterOfMass component.
  • Untick the Use Default … for the properties that the MassAffectors should affect.
Previous Next

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