Skip to content
0.2.0-dev Download ZIP
32 lines ·3.5 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="VehicleBody3D" inherits="RigidBody3D" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A 3D physics body that simulates the behavior of a car.
5 </brief_description>
6 <description>
7 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 [CollisionShape3D] for the main body of the vehicle, you must also add a [VehicleWheel3D] node for each wheel. You should also add a [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 [member brake], [member engine_force], and [member steering] properties. The position or orientation of this node shouldn't be changed directly.
8 [b]Note:[/b] The local forward for this node is [constant Vector3.MODEL_FRONT].
9 [b]Note:[/b] 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 [CollisionShape3D] and [MeshInstance3D] upwards.
10 [b]Note:[/b] 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 [CharacterBody3D] or [RigidBody3D].
11 </description>
12 <tutorials>
13 <link title="Physics introduction">$DOCS_URL/tutorials/physics/physics_introduction.html</link>
14 <link title="Troubleshooting physics issues">$DOCS_URL/tutorials/physics/troubleshooting_physics_issues.html</link>
15 <link title="3D Truck Town Demo">https://store.godotengine.org/asset/godot-foundation/truck-town-demo/</link>
16 </tutorials>
17 <members>
18 <member name="brake" type="float" setter="set_brake" getter="get_brake" default="0.0">
19 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 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.
20 </member>
21 <member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0">
22 Accelerates the vehicle by applying an engine force. The vehicle is only sped up if the wheels that have [member VehicleWheel3D.use_as_traction] set to [code]true[/code] and are in contact with a surface. The [member 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.
23 [b]Note:[/b] 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.
24 A negative value will result in the vehicle reversing.
25 </member>
26 <member name="mass" type="float" setter="set_mass" getter="get_mass" overrides="RigidBody3D" default="40.0" />
27 <member name="steering" type="float" setter="set_steering" getter="get_steering" default="0.0">
28 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 VehicleWheel3D.use_as_steering] set to [code]true[/code] will automatically be rotated.
29 [b]Note:[/b] This property is edited in the inspector in degrees. In code the property is set in radians.
30 </member>
31 </members>
32</class>