Merge pull request #16913 from BastiaanOlij/vehicle_docs
Added documentation for VehicleBody
This commit is contained in:
commit
9d82c82a63
2 changed files with 23 additions and 0 deletions
|
@ -1,8 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VehicleBody" inherits="RigidBody" category="Core" version="3.1-dev">
|
||||
<brief_description>
|
||||
Physics body that simulates the behaviour of a car.
|
||||
</brief_description>
|
||||
<description>
|
||||
This nodes 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 [CollisionShape] for the main body of your vehicle and add [VehicleWheel] nodes for the wheels. You should also add a [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 [member brake], [member engine_force], and [member steering] properties and not change the position or orientation of this node directly.
|
||||
Note that 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 [CollisionShape] and [MeshInstance] upwards.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -12,10 +15,14 @@
|
|||
</methods>
|
||||
<members>
|
||||
<member name="brake" type="float" setter="set_brake" getter="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 [member RigidBody.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking.
|
||||
</member>
|
||||
<member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force">
|
||||
Accelerates the vehicle by applying an engine force. The vehicle is only speed up if the wheels that have [member VehicleWheel.set_use_as_traction] set to true and are in contact with a surface. The [member RigidBody.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 that 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.
|
||||
</member>
|
||||
<member name="steering" type="float" setter="set_steering" getter="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 [member VehicleWheel.set_use_as_steering] set to true will automatically be rotated.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VehicleWheel" inherits="Spatial" category="Core" version="3.1-dev">
|
||||
<brief_description>
|
||||
Physics object that simulates the behaviour of a wheel.
|
||||
</brief_description>
|
||||
<description>
|
||||
This node needs to be used as a child node of [VehicleBody] and simulates the behaviour of one of its wheels. This node also acts as a collider to detect if the wheel is touching a surface.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -13,37 +15,51 @@
|
|||
<return type="float">
|
||||
</return>
|
||||
<description>
|
||||
Returns a value between 0.0 and 1.0 that indicates whether this wheel is skidding. 0.0 is not skidding, 1.0 means the wheel has lost grip.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_in_contact" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<description>
|
||||
Returns true if this wheel is in contact with a surface.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="damping_compression" type="float" setter="set_damping_compression" getter="get_damping_compression">
|
||||
The damping applied to the spring when the spring is being compressed. This value should be between 0.0 (no damping) and 1.0. 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.
|
||||
</member>
|
||||
<member name="damping_relaxation" type="float" setter="set_damping_relaxation" getter="get_damping_relaxation">
|
||||
The damping applied to the spring when relaxing. This value should be between 0.0 (no damping) and 1.0. This value should always be slighly higher then the [member damping_compression] property. For a [member damping_compression] value of 0.3, try a relaxation value of 0.5
|
||||
</member>
|
||||
<member name="suspension_max_force" type="float" setter="set_suspension_max_force" getter="get_suspension_max_force">
|
||||
The maximum force the spring can resist. This value should be higher then a quarter of the [member RigidBody.mass] of the [VehicleBody] or the spring will not carry the weight of the vehicle. Good results are often obtained by a value that is about 3x to 4x this number.
|
||||
</member>
|
||||
<member name="suspension_stiffness" type="float" setter="set_suspension_stiffness" getter="get_suspension_stiffness">
|
||||
This value defines the stiffness of the suspension. Use a value lower then 50 for an offroad car, a value between 50 and 100 for a race car and try something around 200 for something like a Formula 1 car.
|
||||
</member>
|
||||
<member name="suspension_travel" type="float" setter="set_suspension_travel" getter="get_suspension_travel">
|
||||
This is the distance the suspension can travel. As Godots measures are in meters keep this setting relatively low. Try a value between 0.1 and 0.3 depending on the type of car .
|
||||
</member>
|
||||
<member name="use_as_steering" type="bool" setter="set_use_as_steering" getter="is_used_as_steering">
|
||||
If true this wheel will be turned when the car steers.
|
||||
</member>
|
||||
<member name="use_as_traction" type="bool" setter="set_use_as_traction" getter="is_used_as_traction">
|
||||
If true this wheel transfers engine force to the ground to propel the vehicle forward.
|
||||
</member>
|
||||
<member name="wheel_friction_slip" type="float" setter="set_friction_slip" getter="get_friction_slip">
|
||||
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 then the front wheels, or use a lower value to simulate tire wear.
|
||||
It's best to set this to 1.0 when starting out.
|
||||
</member>
|
||||
<member name="wheel_radius" type="float" setter="set_radius" getter="get_radius">
|
||||
The radius of the wheel in meters.
|
||||
</member>
|
||||
<member name="wheel_rest_length" type="float" setter="set_suspension_rest_length" getter="get_suspension_rest_length">
|
||||
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 lenght to move the wheel down to the position it should be in when the car is in rest.
|
||||
</member>
|
||||
<member name="wheel_roll_influence" type="float" setter="set_roll_influence" getter="get_roll_influence">
|
||||
This value effects the roll of your vehicle. If set to 0.0 for all wheels your vehicle will be prone to rolling over while a value of 1.0 will resist body roll.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
|
|
Loading…
Reference in a new issue