class_vehiclebody.rst 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the VehicleBody.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_VehicleBody:
  6. VehicleBody
  7. ===========
  8. **Inherits:** :ref:`RigidBody<class_RigidBody>` **<** :ref:`PhysicsBody<class_PhysicsBody>` **<** :ref:`CollisionObject<class_CollisionObject>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Physics body that simulates the behavior of a car.
  10. Description
  11. -----------
  12. This node implements all the physics logic needed to simulate a car. It is based on the raycast vehicle system commonly found in physics engines. You will need to add a :ref:`CollisionShape<class_CollisionShape>` for the main body of your vehicle and add :ref:`VehicleWheel<class_VehicleWheel>` nodes for the wheels. You should also add a :ref:`MeshInstance<class_MeshInstance>` to this node for the 3D model of your car but this model should not include meshes for the wheels. You should control the vehicle by using the :ref:`brake<class_VehicleBody_property_brake>`, :ref:`engine_force<class_VehicleBody_property_engine_force>`, and :ref:`steering<class_VehicleBody_property_steering>` properties and not change the position or orientation of this node directly.
  13. **Note:** The origin point of your VehicleBody will determine the center of gravity of your vehicle so it is better to keep this low and move the :ref:`CollisionShape<class_CollisionShape>` and :ref:`MeshInstance<class_MeshInstance>` upwards.
  14. Properties
  15. ----------
  16. +---------------------------+--------------------------------------------------------------+------------------+
  17. | :ref:`float<class_float>` | :ref:`brake<class_VehicleBody_property_brake>` | ``0.0`` |
  18. +---------------------------+--------------------------------------------------------------+------------------+
  19. | :ref:`float<class_float>` | :ref:`engine_force<class_VehicleBody_property_engine_force>` | ``0.0`` |
  20. +---------------------------+--------------------------------------------------------------+------------------+
  21. | :ref:`float<class_float>` | mass | **O:** ``40.0`` |
  22. +---------------------------+--------------------------------------------------------------+------------------+
  23. | :ref:`float<class_float>` | :ref:`steering<class_VehicleBody_property_steering>` | ``0.0`` |
  24. +---------------------------+--------------------------------------------------------------+------------------+
  25. | :ref:`float<class_float>` | weight | **O:** ``392.0`` |
  26. +---------------------------+--------------------------------------------------------------+------------------+
  27. Property Descriptions
  28. ---------------------
  29. .. _class_VehicleBody_property_brake:
  30. - :ref:`float<class_float>` **brake**
  31. +-----------+------------------+
  32. | *Default* | ``0.0`` |
  33. +-----------+------------------+
  34. | *Setter* | set_brake(value) |
  35. +-----------+------------------+
  36. | *Getter* | get_brake() |
  37. +-----------+------------------+
  38. 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:`RigidBody.mass<class_RigidBody_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.
  39. ----
  40. .. _class_VehicleBody_property_engine_force:
  41. - :ref:`float<class_float>` **engine_force**
  42. +-----------+-------------------------+
  43. | *Default* | ``0.0`` |
  44. +-----------+-------------------------+
  45. | *Setter* | set_engine_force(value) |
  46. +-----------+-------------------------+
  47. | *Getter* | get_engine_force() |
  48. +-----------+-------------------------+
  49. Accelerates the vehicle by applying an engine force. The vehicle is only speed up if the wheels that have :ref:`VehicleWheel.use_as_traction<class_VehicleWheel_property_use_as_traction>` set to ``true`` and are in contact with a surface. The :ref:`RigidBody.mass<class_RigidBody_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.
  50. **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.
  51. A negative value will result in the vehicle reversing.
  52. ----
  53. .. _class_VehicleBody_property_steering:
  54. - :ref:`float<class_float>` **steering**
  55. +-----------+---------------------+
  56. | *Default* | ``0.0`` |
  57. +-----------+---------------------+
  58. | *Setter* | set_steering(value) |
  59. +-----------+---------------------+
  60. | *Getter* | get_steering() |
  61. +-----------+---------------------+
  62. 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:`VehicleWheel.use_as_steering<class_VehicleWheel_property_use_as_steering>` set to ``true`` will automatically be rotated.