NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class Bone

    Represents a single animated bone element in the vehicle rigging system.

    Inheritance
    object
    Bone
    Namespace: NWH.VehiclePhysics2.Modules.Rigging
    Assembly: NWH.VehiclePhysics2.dll
    Syntax
    [Serializable]
    public class Bone
    Remarks

    A Bone is a fundamental unit of the rigging system that defines how a single transform (such as a suspension arm, axle, or linkage) should be animated based on the position of one or more target transforms. Each bone can be configured to look at its target, stretch to maintain connection, or position itself between two targets.

    Animation Modes: - Look At: Rotates the bone to face the target transform - Stretch: Scales the bone along its Z-axis to maintain connection with the target - Double-Sided: Positions the bone midway between two targets (useful for axles)

    Common Applications: - Suspension arms tracking wheel movement - Driveshafts connecting transmission to wheels - Steering linkages following wheel rotation - Shock absorbers compressing with suspension travel

    Fields

    doubleSided

    Position the bone centered between two target points.

    Declaration
    [Tooltip("Should the object be positioned between two points. Also affects position besides rotation.")]
    public bool doubleSided
    Field Value
    Type Description
    bool
    Remarks

    When enabled, the bone is positioned at the midpoint between targetTransform and targetTransformB, and rotated to look at targetTransform. This is useful for axles or other components that span between two moving parts (like wheels).

    This overrides normal position behavior and requires targetTransformB to be assigned. Typically used for components like drive axles connecting left and right wheels.

    lookAtTarget

    Rotate the bone to face the target transform.

    Declaration
    [Tooltip("Should the object be rotated to look at the target?")]
    public bool lookAtTarget
    Field Value
    Type Description
    bool
    Remarks

    When enabled, the bone continuously rotates to point its forward axis toward the targetTransform. This creates realistic articulation for suspension arms and linkages that need to track wheel or component movement.

    The rotation uses the vehicle's up vector to maintain proper alignment relative to the vehicle body during turning and rolling.

    stretchToTarget

    Scale the bone along its Z-axis to maintain connection with the target.

    Declaration
    [Tooltip("Should the object be stretched between pivot and target?")]
    public bool stretchToTarget
    Field Value
    Type Description
    bool
    Remarks

    When enabled, the bone's Z-axis scale is adjusted based on the distance to the targetTransform. This creates the appearance of stretching or compressing to maintain visual connection as the target moves.

    Useful for: - Shock absorbers compressing and extending - Tie rods adjusting length during steering - Control arms adapting to suspension travel - Any cylindrical component connecting two moving points

    The scale is calculated relative to the initial distance captured during Initialize().

    targetTransform

    The target transform that the bone should track or connect to.

    Declaration
    [Tooltip("The transform that represents the lookAtTarget and stretch target.")]
    public Transform targetTransform
    Field Value
    Type Description
    Transform
    Remarks

    Primary target for bone animation. When lookAtTarget is enabled, the bone rotates to face this transform. When stretchToTarget is enabled, the bone scales to reach this transform.

    Typically assigned to: - Wheel transforms for suspension arms - WheelController transforms for accurate positioning - Other bone transforms for complex linkages - Custom animation targets for special effects

    targetTransformB

    Second target transform for double-sided bone positioning.

    Declaration
    [Tooltip("    Second target. Object will be stretched positioned between targetTransform and targetTransformB if doubleSided is\r\n    true.")]
    public Transform targetTransformB
    Field Value
    Type Description
    Transform
    Remarks

    Only used when doubleSided is enabled. The bone will be positioned at the midpoint between targetTransform and targetTransformB.

    Common usage: - Axles spanning between left and right wheels - Anti-roll bars connecting opposite suspension points - Cross-members linking both sides of the vehicle

    thisTransform

    The transform representing this bone in the vehicle rig.

    Declaration
    [Tooltip("The transform that represents the bone.")]
    public Transform thisTransform
    Field Value
    Type Description
    Transform
    Remarks

    The transform that will be animated by this bone definition. This should be a child transform of the vehicle model, typically part of a rigged mesh hierarchy exported from 3D modeling software.

    This transform's position, rotation, and scale will be modified each frame based on the bone's configuration and target positions.

    Methods

    Initialize()

    Initializes the bone by caching initial distances and scales.

    Declaration
    public void Initialize()
    Remarks

    Called once during module initialization to establish reference values. Stores the initial distance between bone and target, and the initial Z scale. These values are used as references for the stretching calculation.

    Must be called before Update() to ensure proper stretching behavior. The initial configuration represents the "rest" or "neutral" position of the bone.

    Update(Vector3)

    Updates the bone transform based on target position and configuration.

    Declaration
    public void Update(Vector3 up)
    Parameters
    Type Name Description
    Vector3 up

    Vehicle up direction for LookAt alignment.

    Remarks

    Called every frame to update the bone's position, rotation, and scale. The update behavior depends on the configured options:

    - If doubleSided is true: Centers between two targets - If lookAtTarget is true: Rotates to face the target - If stretchToTarget is true: Scales to maintain connection

    The vehicle's up vector ensures proper alignment relative to the vehicle body, maintaining correct orientation during vehicle rotation.

    See Also

    RiggingModule
    WheelComponent
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics