:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/VehicleBody3D.xml. .. _class_VehicleBody3D: VehicleBody3D ============= **Inherits:** :ref:`RigidBody3D` **<** :ref:`PhysicsBody3D` **<** :ref:`CollisionObject3D` **<** :ref:`Node3D` **<** :ref:`Node` **<** :ref:`Object` A 3D physics body that simulates the behavior of a car. .. rst-class:: classref-introduction-group Description ----------- This physics body implements all the physics logic needed to simulate a car. It is based on the raycast vehicle system commonly found in physics engines. Aside from a :ref:`CollisionShape3D` for the main body of the vehicle, you must also add a :ref:`VehicleWheel3D` node for each wheel. You should also add a :ref:`MeshInstance3D` to this node for the 3D model of the vehicle, but this model should generally not include meshes for the wheels. You can control the vehicle by using the :ref:`brake`, :ref:`engine_force`, and :ref:`steering` properties. The position or orientation of this node shouldn't be changed directly. \ **Note:** The local forward for this node is :ref:`Vector3.MODEL_FRONT`. \ **Note:** The origin point of your VehicleBody3D will determine the center of gravity of your vehicle. To make the vehicle more grounded, the origin point is usually kept low, moving the :ref:`CollisionShape3D` and :ref:`MeshInstance3D` upwards. \ **Note:** This class has known issues and isn't designed to provide realistic 3D vehicle physics. If you want advanced vehicle physics, you may have to write your own physics integration using :ref:`CharacterBody3D` or :ref:`RigidBody3D`. .. rst-class:: classref-introduction-group Tutorials --------- - `3D Truck Town Demo `__ .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+ | :ref:`float` | :ref:`brake` | ``0.0`` | +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+ | :ref:`float` | :ref:`engine_force` | ``0.0`` | +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+ | :ref:`float` | mass | ``40.0`` (overrides :ref:`RigidBody3D`) | +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+ | :ref:`float` | :ref:`steering` | ``0.0`` | +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_VehicleBody3D_property_brake: .. rst-class:: classref-property :ref:`float` **brake** = ``0.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_brake**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_brake**\ (\ ) Slows down the vehicle by applying a braking force. The vehicle is only slowed down if the wheels are in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the :ref:`RigidBody3D.mass` of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking. .. rst-class:: classref-item-separator ---- .. _class_VehicleBody3D_property_engine_force: .. rst-class:: classref-property :ref:`float` **engine_force** = ``0.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_engine_force**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_engine_force**\ (\ ) Accelerates the vehicle by applying an engine force. The vehicle is only sped up if the wheels that have :ref:`VehicleWheel3D.use_as_traction` set to ``true`` and are in contact with a surface. The :ref:`RigidBody3D.mass` of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration. \ **Note:** The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears. A negative value will result in the vehicle reversing. .. rst-class:: classref-item-separator ---- .. _class_VehicleBody3D_property_steering: .. rst-class:: classref-property :ref:`float` **steering** = ``0.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_steering**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_steering**\ (\ ) The steering angle for the vehicle. Setting this to a non-zero value will result in the vehicle turning when it's moving. Wheels that have :ref:`VehicleWheel3D.use_as_steering` set to ``true`` will automatically be rotated. \ **Note:** This property is edited in the inspector in degrees. In code the property is set in radians. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`