NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class Bone

    One animated transform in the vehicle rig: a suspension arm, driveshaft, tie rod or shock. Driven off one or two target transforms, with three behaviours that can be combined: look at the target, stretch along Z to reach it, and sit midway between two targets.

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

    Fields

    doubleSided

    Puts the bone at the midpoint of targetTransform and targetTransformB, rotated to look at targetTransform. For parts spanning two moving points, such as a drive axle between the left and right wheels. Needs targetTransformB assigned or the bone is skipped.

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

    lookAtTarget

    Points the bone's forward axis at targetTransform every frame. The vehicle up vector is used as the LookAt up, so the bone stays aligned to the body through roll and yaw.

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

    stretchToTarget

    Scales the bone on Z by the current distance to targetTransform, so shocks, tie rods and control arms stay visually connected as the target moves. The scale is relative to the distance and Z scale captured in Initialize().

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

    targetTransform

    Primary target: what lookAtTarget faces and what stretchToTarget reaches. Usually a wheel or WheelController transform, or another bone for a chained linkage.

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

    targetTransformB

    Second target, used only while doubleSided is on: the bone sits midway between it and targetTransform. Axles, anti-roll bars and cross-members.

    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

    thisTransform

    The transform this bone drives, a child of the vehicle model. Its position, rotation and Z scale are written every frame.

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

    Methods

    Initialize()

    Captures the rest-pose bone-to-target distance and Z scale that stretchToTarget scales against. Must run before the first Update() or stretching has no reference.

    Declaration
    public void Initialize()

    Update(Vector3)

    Writes the bone's position, rotation and scale for this frame: doubleSided centers it between the two targets, lookAtTarget rotates it to face the target, stretchToTarget scales it to reach.

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

    Vehicle up direction for LookAt alignment.

    Update(Vector3, Vector3)

    Compatibility overload. forward is unused, so this is identical to Update(up).

    Declaration
    [Obsolete("forward is unused. Call Update(up).")]
    public void Update(Vector3 forward, Vector3 up)
    Parameters
    Type Name Description
    Vector3 forward
    Vector3 up

    See Also

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