NWH Wheel Controller 3D
Search Results for

    Show / Hide Table of Contents

    Car Controller

    CarController is the small standalone controller included in the Wheel Controller Base Sample. It demonstrates how to write steering, motor torque, brake torque, and handbrake torque to WheelController components.

    It is not a complete powertrain simulation. For engines, transmissions, differentials, modules, effects, and production vehicle tooling, use NWH Vehicle Physics 2.

    Requirements

    1. Import NWH Common Package > Common Base Sample.
    2. Import NWH Wheel Controller 3D > Base Sample.
    3. Put CarController on the vehicle's Rigidbody root.
    4. Keep each WheelController below that root and configure the serialized Wheels list.
    5. Set Edit > Project Settings > Player > Active Input Handling to Input System Package (New) or Both.

    See Quick Start for the complete vehicle setup.

    Wheel list

    Each _Wheel entry contains:

    • wheelController: the wheel that receives control values;
    • power: allows the controller to assign motorTorque;
    • steer: allows the controller to assign steerAngle; and
    • handbrake: allows the handbrake action to assign brakeTorque.

    CarController.Reset() discovers child Wheel Controllers and serializes the initial list when the component is added or reset. Discovery order enables steering on the first two entries, power on every entry, and handbrake on entries after the first two.

    This is one-time discovery, not continuous synchronization. After adding, removing, or reparenting wheels, update the list manually or reset the component and then recheck every flag and torque setting.

    Controller settings

    Field Behavior
    maxMotorTorque Motor torque assigned to powered wheels
    maxBrakeTorque Service-brake and handbrake torque
    maxSteeringAngle Steering angle near zero speed
    minSteeringAngle Steering angle approached as speed rises
    wheels Per-wheel references and control flags
    isPlayerControllable Inherited from Vehicle. Off keeps this car out of the active-vehicle list that cameras and VehicleChanger follow

    The sample smooths steering with Mathf.SmoothDamp. It interpolates from maxSteeringAngle toward minSteeringAngle as vehicle speed increases. Opposite-direction throttle acts as a brake until the vehicle is nearly stopped.

    When CarController is disabled, it clears motor torque and steering and applies maxBrakeTorque to each listed wheel.

    Input

    Awake() creates the shipped CarInputActions wrapper, OnEnable() enables it and OnDisable() disables it again, so a car parked by VehicleChanger owns no live input. FixedUpdate() reads the CarControls action map, and OnDestroy() disposes the wrapper. No scene input provider is required for this sample.

    Action Keyboard Gamepad
    Steering A negative, D positive Left stick left/right
    Throttle S negative, W positive Right trigger positive
    Handbrake Space East button

    The action asset and generated wrapper are in the package's Runtime/Input folder. They are frozen for deterministic package imports. Prefer runtime rebinding or a project-owned copy of the action asset and controller instead of editing a registry package cache. Package maintainers working in a writable embedded package must temporarily enable Generate C# Class, save and regenerate the wrapper, review it, and disable generation again before redistribution.

    Scope

    CarController derives from NWH.Common.Vehicles.Vehicle, so it can participate in Common vehicle lifecycle tools such as VehicleChanger. It drives WheelController directly.

    For a project-specific controller, read the desired input backend in a physics-timed path and assign the current WheelController.steerAngle, motorTorque, and brakeTorque properties. The WheelControllerManager performs wheel simulation automatically.

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