class_vehiclebody3d.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/VehicleBody3D.xml.
  6. .. _class_VehicleBody3D:
  7. VehicleBody3D
  8. =============
  9. **Inherits:** :ref:`RigidBody3D<class_RigidBody3D>` **<** :ref:`PhysicsBody3D<class_PhysicsBody3D>` **<** :ref:`CollisionObject3D<class_CollisionObject3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A 3D physics body that simulates the behavior of a car.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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<class_CollisionShape3D>` for the main body of the vehicle, you must also add a :ref:`VehicleWheel3D<class_VehicleWheel3D>` node for each wheel. You should also add a :ref:`MeshInstance3D<class_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<class_VehicleBody3D_property_brake>`, :ref:`engine_force<class_VehicleBody3D_property_engine_force>`, and :ref:`steering<class_VehicleBody3D_property_steering>` properties. The position or orientation of this node shouldn't be changed directly.
  15. \ **Note:** The local forward for this node is :ref:`Vector3.MODEL_FRONT<class_Vector3_constant_MODEL_FRONT>`.
  16. \ **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<class_CollisionShape3D>` and :ref:`MeshInstance3D<class_MeshInstance3D>` upwards.
  17. \ **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<class_CharacterBody3D>` or :ref:`RigidBody3D<class_RigidBody3D>`.
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - `3D Truck Town Demo <https://godotengine.org/asset-library/asset/2752>`__
  22. .. rst-class:: classref-reftable-group
  23. Properties
  24. ----------
  25. .. table::
  26. :widths: auto
  27. +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`brake<class_VehicleBody3D_property_brake>` | ``0.0`` |
  29. +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`engine_force<class_VehicleBody3D_property_engine_force>` | ``0.0`` |
  31. +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+
  32. | :ref:`float<class_float>` | mass | ``40.0`` (overrides :ref:`RigidBody3D<class_RigidBody3D_property_mass>`) |
  33. +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+
  34. | :ref:`float<class_float>` | :ref:`steering<class_VehicleBody3D_property_steering>` | ``0.0`` |
  35. +---------------------------+----------------------------------------------------------------+--------------------------------------------------------------------------+
  36. .. rst-class:: classref-section-separator
  37. ----
  38. .. rst-class:: classref-descriptions-group
  39. Property Descriptions
  40. ---------------------
  41. .. _class_VehicleBody3D_property_brake:
  42. .. rst-class:: classref-property
  43. :ref:`float<class_float>` **brake** = ``0.0`` :ref:`🔗<class_VehicleBody3D_property_brake>`
  44. .. rst-class:: classref-property-setget
  45. - |void| **set_brake**\ (\ value\: :ref:`float<class_float>`\ )
  46. - :ref:`float<class_float>` **get_brake**\ (\ )
  47. 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<class_RigidBody3D_property_mass>` of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking.
  48. .. rst-class:: classref-item-separator
  49. ----
  50. .. _class_VehicleBody3D_property_engine_force:
  51. .. rst-class:: classref-property
  52. :ref:`float<class_float>` **engine_force** = ``0.0`` :ref:`🔗<class_VehicleBody3D_property_engine_force>`
  53. .. rst-class:: classref-property-setget
  54. - |void| **set_engine_force**\ (\ value\: :ref:`float<class_float>`\ )
  55. - :ref:`float<class_float>` **get_engine_force**\ (\ )
  56. Accelerates the vehicle by applying an engine force. The vehicle is only sped up if the wheels that have :ref:`VehicleWheel3D.use_as_traction<class_VehicleWheel3D_property_use_as_traction>` set to ``true`` and are in contact with a surface. The :ref:`RigidBody3D.mass<class_RigidBody3D_property_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.
  57. \ **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.
  58. A negative value will result in the vehicle reversing.
  59. .. rst-class:: classref-item-separator
  60. ----
  61. .. _class_VehicleBody3D_property_steering:
  62. .. rst-class:: classref-property
  63. :ref:`float<class_float>` **steering** = ``0.0`` :ref:`🔗<class_VehicleBody3D_property_steering>`
  64. .. rst-class:: classref-property-setget
  65. - |void| **set_steering**\ (\ value\: :ref:`float<class_float>`\ )
  66. - :ref:`float<class_float>` **get_steering**\ (\ )
  67. 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<class_VehicleWheel3D_property_use_as_steering>` set to ``true`` will automatically be rotated.
  68. \ **Note:** This property is edited in the inspector in degrees. In code the property is set in radians.
  69. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  70. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  71. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  72. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  73. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  74. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  75. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  76. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  77. .. |void| replace:: :abbr:`void (No return value.)`