NWH Common
Search Results for

    Show / Hide Table of Contents

    Class ShiftingOrigin

    Prevents floating point precision errors by shifting all scene objects back toward world origin when the main camera exceeds the distance threshold.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    ShiftingOrigin
    Namespace: NWH.Common.ShiftingOrigin
    Assembly: NWH.Common.dll
    Syntax
    public class ShiftingOrigin : MonoBehaviour
    Remarks

    As objects move far from world origin [0,0,0], floating point precision degrades causing physics jitter and rendering artifacts. ShiftingOrigin solves this by periodically moving all scene content back toward origin, keeping the player near [0,0,0] at all times.

    The shift is transparent to gameplay - relative positions remain identical. Useful for open world games, flight simulators, or any scenario with large travel distances.

    Only affects the current scene. For multi-scene setups, ensure one ShiftingOrigin instance per loaded scene set.

    Fields

    | Edit this page View Source

    Instance

    Declaration
    public static ShiftingOrigin Instance
    Field Value
    Type Description
    ShiftingOrigin
    | Edit this page View Source

    distanceThreshold

    Distance from world origin in meters that triggers an origin shift. Default 500m works well for most scenarios.

    Declaration
    public float distanceThreshold
    Field Value
    Type Description
    float
    | Edit this page View Source

    onAfterJump

    Event invoked after the origin shift completes and physics is re-synced.

    Declaration
    public UnityEvent onAfterJump
    Field Value
    Type Description
    UnityEvent
    | Edit this page View Source

    onBeforeJump

    Event invoked before the origin shift begins. Rigidbody sleep thresholds are temporarily disabled.

    Declaration
    public UnityEvent onBeforeJump
    Field Value
    Type Description
    UnityEvent

    Properties

    | Edit this page View Source

    TotalOffset

    Cumulative offset applied to all objects since scene start. Useful for tracking absolute world position despite origin shifts.

    Declaration
    public Vector3 TotalOffset { get; }
    Property Value
    Type Description
    Vector3

    Methods

    | Edit this page View Source

    RefreshCaches()

    Refreshes cached references to Rigidbodies and ParticleSystems. Call this if new physics objects or particle systems are added to the scene at runtime.

    Declaration
    public void RefreshCaches()
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics