class_vehiclewheel3d.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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/VehicleWheel3D.xml.
  6. .. _class_VehicleWheel3D:
  7. VehicleWheel3D
  8. ==============
  9. **Inherits:** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A 3D physics body for a :ref:`VehicleBody3D<class_VehicleBody3D>` that simulates the behavior of a wheel.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A node used as a child of a :ref:`VehicleBody3D<class_VehicleBody3D>` parent to simulate the behavior of one of its wheels. This node also acts as a collider to detect if the wheel is touching a surface.
  15. \ **Note:** This class has known issues and isn't designed to provide realistic 3D vehicle physics. If you want advanced vehicle physics, you may need to write your own physics integration using another :ref:`PhysicsBody3D<class_PhysicsBody3D>` class.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - `3D Truck Town Demo <https://godotengine.org/asset-library/asset/2752>`__
  20. .. rst-class:: classref-reftable-group
  21. Properties
  22. ----------
  23. .. table::
  24. :widths: auto
  25. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  26. | :ref:`float<class_float>` | :ref:`brake<class_VehicleWheel3D_property_brake>` | ``0.0`` |
  27. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`damping_compression<class_VehicleWheel3D_property_damping_compression>` | ``0.83`` |
  29. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`damping_relaxation<class_VehicleWheel3D_property_damping_relaxation>` | ``0.88`` |
  31. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`engine_force<class_VehicleWheel3D_property_engine_force>` | ``0.0`` |
  33. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  34. | :ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` | physics_interpolation_mode | ``2`` (overrides :ref:`Node<class_Node_property_physics_interpolation_mode>`) |
  35. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`steering<class_VehicleWheel3D_property_steering>` | ``0.0`` |
  37. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  38. | :ref:`float<class_float>` | :ref:`suspension_max_force<class_VehicleWheel3D_property_suspension_max_force>` | ``6000.0`` |
  39. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`suspension_stiffness<class_VehicleWheel3D_property_suspension_stiffness>` | ``5.88`` |
  41. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`suspension_travel<class_VehicleWheel3D_property_suspension_travel>` | ``0.2`` |
  43. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`use_as_steering<class_VehicleWheel3D_property_use_as_steering>` | ``false`` |
  45. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`use_as_traction<class_VehicleWheel3D_property_use_as_traction>` | ``false`` |
  47. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  48. | :ref:`float<class_float>` | :ref:`wheel_friction_slip<class_VehicleWheel3D_property_wheel_friction_slip>` | ``10.5`` |
  49. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`wheel_radius<class_VehicleWheel3D_property_wheel_radius>` | ``0.5`` |
  51. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  52. | :ref:`float<class_float>` | :ref:`wheel_rest_length<class_VehicleWheel3D_property_wheel_rest_length>` | ``0.15`` |
  53. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  54. | :ref:`float<class_float>` | :ref:`wheel_roll_influence<class_VehicleWheel3D_property_wheel_roll_influence>` | ``0.1`` |
  55. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  56. .. rst-class:: classref-reftable-group
  57. Methods
  58. -------
  59. .. table::
  60. :widths: auto
  61. +-------------------------------+-----------------------------------------------------------------------------------------+
  62. | :ref:`Node3D<class_Node3D>` | :ref:`get_contact_body<class_VehicleWheel3D_method_get_contact_body>`\ (\ ) |const| |
  63. +-------------------------------+-----------------------------------------------------------------------------------------+
  64. | :ref:`Vector3<class_Vector3>` | :ref:`get_contact_normal<class_VehicleWheel3D_method_get_contact_normal>`\ (\ ) |const| |
  65. +-------------------------------+-----------------------------------------------------------------------------------------+
  66. | :ref:`Vector3<class_Vector3>` | :ref:`get_contact_point<class_VehicleWheel3D_method_get_contact_point>`\ (\ ) |const| |
  67. +-------------------------------+-----------------------------------------------------------------------------------------+
  68. | :ref:`float<class_float>` | :ref:`get_rpm<class_VehicleWheel3D_method_get_rpm>`\ (\ ) |const| |
  69. +-------------------------------+-----------------------------------------------------------------------------------------+
  70. | :ref:`float<class_float>` | :ref:`get_skidinfo<class_VehicleWheel3D_method_get_skidinfo>`\ (\ ) |const| |
  71. +-------------------------------+-----------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`is_in_contact<class_VehicleWheel3D_method_is_in_contact>`\ (\ ) |const| |
  73. +-------------------------------+-----------------------------------------------------------------------------------------+
  74. .. rst-class:: classref-section-separator
  75. ----
  76. .. rst-class:: classref-descriptions-group
  77. Property Descriptions
  78. ---------------------
  79. .. _class_VehicleWheel3D_property_brake:
  80. .. rst-class:: classref-property
  81. :ref:`float<class_float>` **brake** = ``0.0`` :ref:`🔗<class_VehicleWheel3D_property_brake>`
  82. .. rst-class:: classref-property-setget
  83. - |void| **set_brake**\ (\ value\: :ref:`float<class_float>`\ )
  84. - :ref:`float<class_float>` **get_brake**\ (\ )
  85. Slows down the wheel by applying a braking force. The wheel is only slowed down if it is 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.
  86. .. rst-class:: classref-item-separator
  87. ----
  88. .. _class_VehicleWheel3D_property_damping_compression:
  89. .. rst-class:: classref-property
  90. :ref:`float<class_float>` **damping_compression** = ``0.83`` :ref:`🔗<class_VehicleWheel3D_property_damping_compression>`
  91. .. rst-class:: classref-property-setget
  92. - |void| **set_damping_compression**\ (\ value\: :ref:`float<class_float>`\ )
  93. - :ref:`float<class_float>` **get_damping_compression**\ (\ )
  94. The damping applied to the suspension spring when being compressed, meaning when the wheel is moving up relative to the vehicle. It is measured in Newton-seconds per millimeter (N⋅s/mm), or megagrams per second (Mg/s). This value should be between 0.0 (no damping) and 1.0, but may be more. A value of 0.0 means the car will keep bouncing as the spring keeps its energy. A good value for this is around 0.3 for a normal car, 0.5 for a race car.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_VehicleWheel3D_property_damping_relaxation:
  98. .. rst-class:: classref-property
  99. :ref:`float<class_float>` **damping_relaxation** = ``0.88`` :ref:`🔗<class_VehicleWheel3D_property_damping_relaxation>`
  100. .. rst-class:: classref-property-setget
  101. - |void| **set_damping_relaxation**\ (\ value\: :ref:`float<class_float>`\ )
  102. - :ref:`float<class_float>` **get_damping_relaxation**\ (\ )
  103. The damping applied to the suspension spring when rebounding or extending, meaning when the wheel is moving down relative to the vehicle. It is measured in Newton-seconds per millimeter (N⋅s/mm), or megagrams per second (Mg/s). This value should be between 0.0 (no damping) and 1.0, but may be more. This value should always be slightly higher than the :ref:`damping_compression<class_VehicleWheel3D_property_damping_compression>` property. For a :ref:`damping_compression<class_VehicleWheel3D_property_damping_compression>` value of 0.3, try a relaxation value of 0.5.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_VehicleWheel3D_property_engine_force:
  107. .. rst-class:: classref-property
  108. :ref:`float<class_float>` **engine_force** = ``0.0`` :ref:`🔗<class_VehicleWheel3D_property_engine_force>`
  109. .. rst-class:: classref-property-setget
  110. - |void| **set_engine_force**\ (\ value\: :ref:`float<class_float>`\ )
  111. - :ref:`float<class_float>` **get_engine_force**\ (\ )
  112. Accelerates the wheel by applying an engine force. The wheel is only sped up if it is 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.
  113. \ **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.
  114. A negative value will result in the wheel reversing.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_VehicleWheel3D_property_steering:
  118. .. rst-class:: classref-property
  119. :ref:`float<class_float>` **steering** = ``0.0`` :ref:`🔗<class_VehicleWheel3D_property_steering>`
  120. .. rst-class:: classref-property-setget
  121. - |void| **set_steering**\ (\ value\: :ref:`float<class_float>`\ )
  122. - :ref:`float<class_float>` **get_steering**\ (\ )
  123. The steering angle for the wheel, in radians. Setting this to a non-zero value will result in the vehicle turning when it's moving.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_VehicleWheel3D_property_suspension_max_force:
  127. .. rst-class:: classref-property
  128. :ref:`float<class_float>` **suspension_max_force** = ``6000.0`` :ref:`🔗<class_VehicleWheel3D_property_suspension_max_force>`
  129. .. rst-class:: classref-property-setget
  130. - |void| **set_suspension_max_force**\ (\ value\: :ref:`float<class_float>`\ )
  131. - :ref:`float<class_float>` **get_suspension_max_force**\ (\ )
  132. The maximum force the spring can resist. This value should be higher than a quarter of the :ref:`RigidBody3D.mass<class_RigidBody3D_property_mass>` of the :ref:`VehicleBody3D<class_VehicleBody3D>` or the spring will not carry the weight of the vehicle. Good results are often obtained by a value that is about 3× to 4× this number.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_VehicleWheel3D_property_suspension_stiffness:
  136. .. rst-class:: classref-property
  137. :ref:`float<class_float>` **suspension_stiffness** = ``5.88`` :ref:`🔗<class_VehicleWheel3D_property_suspension_stiffness>`
  138. .. rst-class:: classref-property-setget
  139. - |void| **set_suspension_stiffness**\ (\ value\: :ref:`float<class_float>`\ )
  140. - :ref:`float<class_float>` **get_suspension_stiffness**\ (\ )
  141. The stiffness of the suspension, measured in Newtons per millimeter (N/mm), or megagrams per second squared (Mg/s²). Use a value lower than 50 for an off-road car, a value between 50 and 100 for a race car and try something around 200 for something like a Formula 1 car.
  142. .. rst-class:: classref-item-separator
  143. ----
  144. .. _class_VehicleWheel3D_property_suspension_travel:
  145. .. rst-class:: classref-property
  146. :ref:`float<class_float>` **suspension_travel** = ``0.2`` :ref:`🔗<class_VehicleWheel3D_property_suspension_travel>`
  147. .. rst-class:: classref-property-setget
  148. - |void| **set_suspension_travel**\ (\ value\: :ref:`float<class_float>`\ )
  149. - :ref:`float<class_float>` **get_suspension_travel**\ (\ )
  150. This is the distance the suspension can travel. As Godot units are equivalent to meters, keep this setting relatively low. Try a value between 0.1 and 0.3 depending on the type of car.
  151. .. rst-class:: classref-item-separator
  152. ----
  153. .. _class_VehicleWheel3D_property_use_as_steering:
  154. .. rst-class:: classref-property
  155. :ref:`bool<class_bool>` **use_as_steering** = ``false`` :ref:`🔗<class_VehicleWheel3D_property_use_as_steering>`
  156. .. rst-class:: classref-property-setget
  157. - |void| **set_use_as_steering**\ (\ value\: :ref:`bool<class_bool>`\ )
  158. - :ref:`bool<class_bool>` **is_used_as_steering**\ (\ )
  159. If ``true``, this wheel will be turned when the car steers. This value is used in conjunction with :ref:`VehicleBody3D.steering<class_VehicleBody3D_property_steering>` and ignored if you are using the per-wheel :ref:`steering<class_VehicleWheel3D_property_steering>` value instead.
  160. .. rst-class:: classref-item-separator
  161. ----
  162. .. _class_VehicleWheel3D_property_use_as_traction:
  163. .. rst-class:: classref-property
  164. :ref:`bool<class_bool>` **use_as_traction** = ``false`` :ref:`🔗<class_VehicleWheel3D_property_use_as_traction>`
  165. .. rst-class:: classref-property-setget
  166. - |void| **set_use_as_traction**\ (\ value\: :ref:`bool<class_bool>`\ )
  167. - :ref:`bool<class_bool>` **is_used_as_traction**\ (\ )
  168. If ``true``, this wheel transfers engine force to the ground to propel the vehicle forward. This value is used in conjunction with :ref:`VehicleBody3D.engine_force<class_VehicleBody3D_property_engine_force>` and ignored if you are using the per-wheel :ref:`engine_force<class_VehicleWheel3D_property_engine_force>` value instead.
  169. .. rst-class:: classref-item-separator
  170. ----
  171. .. _class_VehicleWheel3D_property_wheel_friction_slip:
  172. .. rst-class:: classref-property
  173. :ref:`float<class_float>` **wheel_friction_slip** = ``10.5`` :ref:`🔗<class_VehicleWheel3D_property_wheel_friction_slip>`
  174. .. rst-class:: classref-property-setget
  175. - |void| **set_friction_slip**\ (\ value\: :ref:`float<class_float>`\ )
  176. - :ref:`float<class_float>` **get_friction_slip**\ (\ )
  177. This determines how much grip this wheel has. It is combined with the friction setting of the surface the wheel is in contact with. 0.0 means no grip, 1.0 is normal grip. For a drift car setup, try setting the grip of the rear wheels slightly lower than the front wheels, or use a lower value to simulate tire wear.
  178. It's best to set this to 1.0 when starting out.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_VehicleWheel3D_property_wheel_radius:
  182. .. rst-class:: classref-property
  183. :ref:`float<class_float>` **wheel_radius** = ``0.5`` :ref:`🔗<class_VehicleWheel3D_property_wheel_radius>`
  184. .. rst-class:: classref-property-setget
  185. - |void| **set_radius**\ (\ value\: :ref:`float<class_float>`\ )
  186. - :ref:`float<class_float>` **get_radius**\ (\ )
  187. The radius of the wheel in meters.
  188. .. rst-class:: classref-item-separator
  189. ----
  190. .. _class_VehicleWheel3D_property_wheel_rest_length:
  191. .. rst-class:: classref-property
  192. :ref:`float<class_float>` **wheel_rest_length** = ``0.15`` :ref:`🔗<class_VehicleWheel3D_property_wheel_rest_length>`
  193. .. rst-class:: classref-property-setget
  194. - |void| **set_suspension_rest_length**\ (\ value\: :ref:`float<class_float>`\ )
  195. - :ref:`float<class_float>` **get_suspension_rest_length**\ (\ )
  196. This is the distance in meters the wheel is lowered from its origin point. Don't set this to 0.0 and move the wheel into position, instead move the origin point of your wheel (the gizmo in Godot) to the position the wheel will take when bottoming out, then use the rest length to move the wheel down to the position it should be in when the car is in rest.
  197. .. rst-class:: classref-item-separator
  198. ----
  199. .. _class_VehicleWheel3D_property_wheel_roll_influence:
  200. .. rst-class:: classref-property
  201. :ref:`float<class_float>` **wheel_roll_influence** = ``0.1`` :ref:`🔗<class_VehicleWheel3D_property_wheel_roll_influence>`
  202. .. rst-class:: classref-property-setget
  203. - |void| **set_roll_influence**\ (\ value\: :ref:`float<class_float>`\ )
  204. - :ref:`float<class_float>` **get_roll_influence**\ (\ )
  205. This value affects the roll of your vehicle. If set to 1.0 for all wheels, your vehicle will resist body roll, while a value of 0.0 will be prone to rolling over.
  206. .. rst-class:: classref-section-separator
  207. ----
  208. .. rst-class:: classref-descriptions-group
  209. Method Descriptions
  210. -------------------
  211. .. _class_VehicleWheel3D_method_get_contact_body:
  212. .. rst-class:: classref-method
  213. :ref:`Node3D<class_Node3D>` **get_contact_body**\ (\ ) |const| :ref:`🔗<class_VehicleWheel3D_method_get_contact_body>`
  214. Returns the contacting body node if valid in the tree, as :ref:`Node3D<class_Node3D>`. At the moment, :ref:`GridMap<class_GridMap>` is not supported so the node will be always of type :ref:`PhysicsBody3D<class_PhysicsBody3D>`.
  215. Returns ``null`` if the wheel is not in contact with a surface, or the contact body is not a :ref:`PhysicsBody3D<class_PhysicsBody3D>`.
  216. .. rst-class:: classref-item-separator
  217. ----
  218. .. _class_VehicleWheel3D_method_get_contact_normal:
  219. .. rst-class:: classref-method
  220. :ref:`Vector3<class_Vector3>` **get_contact_normal**\ (\ ) |const| :ref:`🔗<class_VehicleWheel3D_method_get_contact_normal>`
  221. Returns the normal of the suspension's collision in world space if the wheel is in contact. If the wheel isn't in contact with anything, returns a vector pointing directly along the suspension axis toward the vehicle in world space.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _class_VehicleWheel3D_method_get_contact_point:
  225. .. rst-class:: classref-method
  226. :ref:`Vector3<class_Vector3>` **get_contact_point**\ (\ ) |const| :ref:`🔗<class_VehicleWheel3D_method_get_contact_point>`
  227. Returns the point of the suspension's collision in world space if the wheel is in contact. If the wheel isn't in contact with anything, returns the maximum point of the wheel's ray cast in world space, which is defined by ``wheel_rest_length + wheel_radius``.
  228. .. rst-class:: classref-item-separator
  229. ----
  230. .. _class_VehicleWheel3D_method_get_rpm:
  231. .. rst-class:: classref-method
  232. :ref:`float<class_float>` **get_rpm**\ (\ ) |const| :ref:`🔗<class_VehicleWheel3D_method_get_rpm>`
  233. Returns the rotational speed of the wheel in revolutions per minute.
  234. .. rst-class:: classref-item-separator
  235. ----
  236. .. _class_VehicleWheel3D_method_get_skidinfo:
  237. .. rst-class:: classref-method
  238. :ref:`float<class_float>` **get_skidinfo**\ (\ ) |const| :ref:`🔗<class_VehicleWheel3D_method_get_skidinfo>`
  239. Returns a value between 0.0 and 1.0 that indicates whether this wheel is skidding. 0.0 is skidding (the wheel has lost grip, e.g. icy terrain), 1.0 means not skidding (the wheel has full grip, e.g. dry asphalt road).
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_VehicleWheel3D_method_is_in_contact:
  243. .. rst-class:: classref-method
  244. :ref:`bool<class_bool>` **is_in_contact**\ (\ ) |const| :ref:`🔗<class_VehicleWheel3D_method_is_in_contact>`
  245. Returns ``true`` if this wheel is in contact with a surface.
  246. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  247. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  248. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  249. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  250. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  251. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  252. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  253. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  254. .. |void| replace:: :abbr:`void (No return value.)`