docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class VehicleUtilities

    Various vehicle utilities

    Inheritance
    object
    VehicleUtilities
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Vehicles
    Assembly: com.unity.vehicles.dll
    Syntax
    public static class VehicleUtilities

    Methods

    GetCenteredThreadPoint(in WheelOnVehicle, in RigidTransform, in RigidTransform)

    Gets the downward center point of the wheel

    Declaration
    public static float3 GetCenteredThreadPoint(in WheelOnVehicle wheelOnVehicle, in RigidTransform steeredSuspensionWorldTransform, in RigidTransform wheelWorldTransform)
    Parameters
    Type Name Description
    WheelOnVehicle wheelOnVehicle

    The target wheel.

    RigidTransform steeredSuspensionWorldTransform

    The steered suspension transform

    RigidTransform wheelWorldTransform

    The world transform of the wheel

    Returns
    Type Description
    float3

    The downward center point of the wheel

    GetHitBodyVelocity(in PhysicsWorld, in ColliderCastHit, out float3)

    Returns the velocity of a hit rigidbody at the hit point

    Declaration
    public static void GetHitBodyVelocity(in PhysicsWorld physicsWorld, in ColliderCastHit hit, out float3 hitBodyVelocity)
    Parameters
    Type Name Description
    PhysicsWorld physicsWorld

    The PhysicsWorld

    ColliderCastHit hit

    The hit

    float3 hitBodyVelocity

    The calculated velocity of the hit body

    GetSteeredSuspensionLocalTransform(in WheelOnVehicle)

    Calculates the local transform of the wheel's suspension with steering taken into account.

    Declaration
    public static RigidTransform GetSteeredSuspensionLocalTransform(in WheelOnVehicle wheelOnVehicle)
    Parameters
    Type Name Description
    WheelOnVehicle wheelOnVehicle

    The target wheel.

    Returns
    Type Description
    RigidTransform

    World transform of the wheel's suspension.

    GetSteeredSuspensionWorldTransform(in RigidTransform, in WheelOnVehicle)

    Calculates the world transform of the wheel's suspension.

    Declaration
    public static RigidTransform GetSteeredSuspensionWorldTransform(in RigidTransform vehicleTransform, in WheelOnVehicle wheelOnVehicle)
    Parameters
    Type Name Description
    RigidTransform vehicleTransform

    The transform of the vehicle the suspension belongs to.

    WheelOnVehicle wheelOnVehicle

    The target wheel.

    Returns
    Type Description
    RigidTransform

    World transform of the wheel's suspension.

    GetSuspensionLocalDirection(in WheelOnVehicle)

    Gets the local direction of the suspension

    Declaration
    public static float3 GetSuspensionLocalDirection(in WheelOnVehicle wheelOnVehicle)
    Parameters
    Type Name Description
    WheelOnVehicle wheelOnVehicle

    The target wheel.

    Returns
    Type Description
    float3

    The local direction of the suspension

    GetSuspensionWorldDirection(in RigidTransform)

    Gets the world direction of the suspension

    Declaration
    public static float3 GetSuspensionWorldDirection(in RigidTransform steeredSuspensionWorldTransform)
    Parameters
    Type Name Description
    RigidTransform steeredSuspensionWorldTransform

    The steered suspension world transform

    Returns
    Type Description
    float3

    The world direction of the suspension

    GetSuspensionWorldDirection(in RigidTransform, in WheelOnVehicle)

    Gets the world direction of the suspension

    Declaration
    public static float3 GetSuspensionWorldDirection(in RigidTransform vehicleTransform, in WheelOnVehicle wheelOnVehicle)
    Parameters
    Type Name Description
    RigidTransform vehicleTransform

    The transform of the vehicle the suspension belongs to.

    WheelOnVehicle wheelOnVehicle

    The target wheel.

    Returns
    Type Description
    float3

    The world direction of the suspension

    GetWheelForward(in RigidTransform)

    Gets the wheel forward direction

    Declaration
    public static float3 GetWheelForward(in RigidTransform steeredSuspensionTransform)
    Parameters
    Type Name Description
    RigidTransform steeredSuspensionTransform

    The steered suspension transform

    Returns
    Type Description
    float3

    The wheel forward direction

    GetWheelLocalTransform(in WheelOnVehicle)

    Calculates the local transform of the wheel.

    Declaration
    public static RigidTransform GetWheelLocalTransform(in WheelOnVehicle wheelOnVehicle)
    Parameters
    Type Name Description
    WheelOnVehicle wheelOnVehicle

    The target wheel.

    Returns
    Type Description
    RigidTransform

    Local transform of the wheel.

    GetWheelRight(in RigidTransform)

    Gets the wheel right direction

    Declaration
    public static float3 GetWheelRight(in RigidTransform steeredSuspensionTransform)
    Parameters
    Type Name Description
    RigidTransform steeredSuspensionTransform

    The steered suspension transform

    Returns
    Type Description
    float3

    The wheel right direction

    GetWheelTransforms(in RigidTransform, in WheelOnVehicle, out RigidTransform, out RigidTransform, out float3, out float3, out float3, out float3, out float3)

    Returns all relevant wheel and suspension transforms information

    Declaration
    public static void GetWheelTransforms(in RigidTransform vehicleTransform, in WheelOnVehicle wheelOnVehicle, out RigidTransform steeredSuspensionWorldTransform, out RigidTransform wheelWorldTransform, out float3 suspensionDirection, out float3 centeredThreadPoint, out float3 wheelForward, out float3 wheelRight, out float3 wheelUp)
    Parameters
    Type Name Description
    RigidTransform vehicleTransform

    The transform of the vehicle the suspension belongs to.

    WheelOnVehicle wheelOnVehicle

    The target wheel.

    RigidTransform steeredSuspensionWorldTransform

    The steered suspension transform

    RigidTransform wheelWorldTransform

    The world transform of the wheel

    float3 suspensionDirection

    The world suspension direction

    float3 centeredThreadPoint

    The centered thread point on the wheel

    float3 wheelForward

    The wheel forward direction

    float3 wheelRight

    The wheel right direction

    float3 wheelUp

    The wheel up direction

    GetWheelUp(in RigidTransform)

    Gets the wheel up direction

    Declaration
    public static float3 GetWheelUp(in RigidTransform steeredSuspensionTransform)
    Parameters
    Type Name Description
    RigidTransform steeredSuspensionTransform

    The steered suspension transform

    Returns
    Type Description
    float3

    The wheel up direction

    GetWheelWorldTransform(in RigidTransform, float)

    Calculates the world transform of the wheel.

    Declaration
    public static RigidTransform GetWheelWorldTransform(in RigidTransform steeredSuspensionWorldTransform, float suspensionLength)
    Parameters
    Type Name Description
    RigidTransform steeredSuspensionWorldTransform

    The steered suspension world transform

    float suspensionLength

    The current length of the suspension

    Returns
    Type Description
    RigidTransform

    The world transform of the wheel

    GetWheelWorldTransform(in RigidTransform, in WheelOnVehicle)

    Calculates the world transform of the wheel.

    Declaration
    public static RigidTransform GetWheelWorldTransform(in RigidTransform vehicleTransform, in WheelOnVehicle wheelOnVehicle)
    Parameters
    Type Name Description
    RigidTransform vehicleTransform

    The transform of the vehicle the suspension belongs to.

    WheelOnVehicle wheelOnVehicle

    The target wheel.

    Returns
    Type Description
    RigidTransform

    World transform of the wheel. Note that this transform does not include any spin around the axle.

    IsBodyDynamic(in PhysicsWorld, int)

    Returns true if the Rigidbody is dynamic.

    Declaration
    public static bool IsBodyDynamic(in PhysicsWorld physicsWorld, int rigidbodyIndex)
    Parameters
    Type Name Description
    PhysicsWorld physicsWorld

    Physics world.

    int rigidbodyIndex

    Index of the body.

    Returns
    Type Description
    bool

    True if dynamic (non-kinematic) Rigidbody.

    IsBodyNonStatic(in PhysicsWorld, int)

    Returns true if the body is a Rigidbody, dynamic or kinematic.

    Declaration
    public static bool IsBodyNonStatic(in PhysicsWorld physicsWorld, int rigidbodyIndex)
    Parameters
    Type Name Description
    PhysicsWorld physicsWorld

    Physics world.

    int rigidbodyIndex

    Index of the body.

    Returns
    Type Description
    bool

    True if Rigidbody.

    TryAddWheel(Entity, Entity, Entity, in RigidTransform, in ComponentLookup<Wheel>, ref BufferLookup<WheelOnVehicle>, ref ComponentLookup<WheelOnVehicleReference>, ref ComponentLookup<VehicleUpdateColliders>, ref ComponentLookup<VehicleUpdateWheelData>, ref BufferLookup<VehicleWheelEvent>)

    Tries to add a wheel to the vehicle.

    Declaration
    public static bool TryAddWheel(Entity vehicleEntity, Entity wheelEntity, Entity pairedWheelEntity, in RigidTransform wheelLocalTransformOnVehicle, in ComponentLookup<Wheel> wheelLookup, ref BufferLookup<WheelOnVehicle> wheelOnVehicleBufferLookup, ref ComponentLookup<WheelOnVehicleReference> wheelOnVehicleReferenceLookup, ref ComponentLookup<VehicleUpdateColliders> vehicleUpdateCollidersLookup, ref ComponentLookup<VehicleUpdateWheelData> vehicleUpdateWheelDataLookup, ref BufferLookup<VehicleWheelEvent> vehicleWheelEventsLookup)
    Parameters
    Type Name Description
    Entity vehicleEntity

    Vehicle entity to which to add te wheel to.

    Entity wheelEntity

    Wheel which is to be added.

    Entity pairedWheelEntity

    Wheel entity that is sharing the same axle with the wheel to be added (if any).

    RigidTransform wheelLocalTransformOnVehicle

    Local RigidTransform representing the wheel position.

    ComponentLookup<Wheel> wheelLookup

    Wheel lookup.

    BufferLookup<WheelOnVehicle> wheelOnVehicleBufferLookup

    WheelOnVehicle lookup.

    ComponentLookup<WheelOnVehicleReference> wheelOnVehicleReferenceLookup

    WheelOnVehicleReference lookup.

    ComponentLookup<VehicleUpdateColliders> vehicleUpdateCollidersLookup

    VehicleUpdateColliders lookup.

    ComponentLookup<VehicleUpdateWheelData> vehicleUpdateWheelDataLookup

    VehicleUpdateWheelData lookup.

    BufferLookup<VehicleWheelEvent> vehicleWheelEventsLookup

    VehicleWheelEvent lookup.

    Returns
    Type Description
    bool

    True if successful.

    TryGetWheelOnVehicle(Entity, in DynamicBuffer<WheelOnVehicle>, out WheelOnVehicle, out int)

    Tries to find a vehicle wheel on the vehicle, based on a wheel entity.

    Declaration
    public static bool TryGetWheelOnVehicle(Entity wheelEntity, in DynamicBuffer<WheelOnVehicle> wheelsOnVehicleBuffer, out WheelOnVehicle wheelOnVehicle, out int vehicleWheelIndex)
    Parameters
    Type Name Description
    Entity wheelEntity

    The wheel entity to find

    DynamicBuffer<WheelOnVehicle> wheelsOnVehicleBuffer

    The vehicle wheels buffer on the target vehicle

    WheelOnVehicle wheelOnVehicle

    The found vehicle wheel

    int vehicleWheelIndex

    The found vehicle wheel index

    Returns
    Type Description
    bool

    True if wheel was found

    TryRemoveWheel(Entity, int, ref BufferLookup<WheelOnVehicle>, ref ComponentLookup<WheelOnVehicleReference>, ref ComponentLookup<VehicleUpdateColliders>, ref ComponentLookup<VehicleUpdateWheelData>, ref BufferLookup<VehicleWheelEvent>, out WheelOnVehicle)

    Removes a wheel from a vehicle

    Declaration
    public static bool TryRemoveWheel(Entity vehicleEntity, int wheelIndex, ref BufferLookup<WheelOnVehicle> wheelOnVehicleBufferLookup, ref ComponentLookup<WheelOnVehicleReference> wheelOnVehicleReferenceLookup, ref ComponentLookup<VehicleUpdateColliders> vehicleUpdateCollidersLookup, ref ComponentLookup<VehicleUpdateWheelData> vehicleUpdateWheelDataLookup, ref BufferLookup<VehicleWheelEvent> vehicleWheelEventsLookup, out WheelOnVehicle removedWheel)
    Parameters
    Type Name Description
    Entity vehicleEntity

    The vehicle entity

    int wheelIndex

    The index of the wheel to remove on the vehicle

    BufferLookup<WheelOnVehicle> wheelOnVehicleBufferLookup

    The WheelOnVehicle buffer lookup

    ComponentLookup<WheelOnVehicleReference> wheelOnVehicleReferenceLookup

    The WheelOnVehicleReference component lookup

    ComponentLookup<VehicleUpdateColliders> vehicleUpdateCollidersLookup

    The VehicleUpdateColliders component lookup

    ComponentLookup<VehicleUpdateWheelData> vehicleUpdateWheelDataLookup

    The VehicleUpdateWheelData component lookup

    BufferLookup<VehicleWheelEvent> vehicleWheelEventsLookup

    The VehicleWheelEvent component lookup

    WheelOnVehicle removedWheel

    The removed wheel data

    Returns
    Type Description
    bool

    True if successful.

    TryRemoveWheel(Entity, Entity, ref BufferLookup<WheelOnVehicle>, ref ComponentLookup<WheelOnVehicleReference>, ref ComponentLookup<VehicleUpdateColliders>, ref ComponentLookup<VehicleUpdateWheelData>, ref BufferLookup<VehicleWheelEvent>, out WheelOnVehicle)

    Removes a wheel from a vehicle

    Declaration
    public static bool TryRemoveWheel(Entity vehicleEntity, Entity wheelEntity, ref BufferLookup<WheelOnVehicle> wheelOnVehicleBufferLookup, ref ComponentLookup<WheelOnVehicleReference> wheelOnVehicleReferenceLookup, ref ComponentLookup<VehicleUpdateColliders> vehicleUpdateCollidersLookup, ref ComponentLookup<VehicleUpdateWheelData> vehicleUpdateWheelDataLookup, ref BufferLookup<VehicleWheelEvent> vehicleWheelEventsLookup, out WheelOnVehicle removedWheel)
    Parameters
    Type Name Description
    Entity vehicleEntity

    The vehicle entity

    Entity wheelEntity

    The wheel entity to remove

    BufferLookup<WheelOnVehicle> wheelOnVehicleBufferLookup

    The WheelOnVehicle buffer lookup

    ComponentLookup<WheelOnVehicleReference> wheelOnVehicleReferenceLookup

    The WheelOnVehicleReference component lookup

    ComponentLookup<VehicleUpdateColliders> vehicleUpdateCollidersLookup

    The VehicleUpdateColliders component lookup

    ComponentLookup<VehicleUpdateWheelData> vehicleUpdateWheelDataLookup

    The VehicleUpdateWheelData component lookup

    BufferLookup<VehicleWheelEvent> vehicleWheelEventsLookup

    The VehicleWheelEvent component lookup

    WheelOnVehicle removedWheel

    The removed wheel data

    Returns
    Type Description
    bool

    True if successful.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)