mirror of
https://github.com/godotengine/godot
synced 2024-09-05 20:09:26 +00:00
![Ricardo Buring](/assets/img/avatar_default.png)
Using non-uniform scale is known to cause many issues. Add warnings to the editor and to the class reference. Also remove the warning from SoftBody3D since it is not relevant there: it simulates in global space.
30 lines
3.3 KiB
XML
30 lines
3.3 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="VehicleBody3D" inherits="RigidBody3D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
|
<brief_description>
|
|
Physics body that simulates the behavior of a car.
|
|
</brief_description>
|
|
<description>
|
|
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 [CollisionShape3D] for the main body of your vehicle and add [VehicleWheel3D] nodes for the wheels. You should also add a [MeshInstance3D] 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.
|
|
[b]Note:[/b] The origin point of your VehicleBody3D will determine the center of gravity of your vehicle so it is better to keep this low and move the [CollisionShape3D] and [MeshInstance3D] upwards.
|
|
[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 will probably have to write your own physics integration using another [PhysicsBody3D] class.
|
|
[b]Warning:[/b] With a non-uniform scale this node will probably not function as expected. Please make sure to keep its scale uniform (i.e. the same on all axes), and change the size(s) of its collision shape(s) instead.
|
|
</description>
|
|
<tutorials>
|
|
<link title="3D Truck Town Demo">https://godotengine.org/asset-library/asset/524</link>
|
|
</tutorials>
|
|
<members>
|
|
<member name="brake" type="float" setter="set_brake" getter="get_brake" default="0.0">
|
|
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.
|
|
</member>
|
|
<member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0">
|
|
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.
|
|
[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.
|
|
A negative value will result in the vehicle reversing.
|
|
</member>
|
|
<member name="mass" type="float" setter="set_mass" getter="get_mass" overrides="RigidBody3D" default="40.0" />
|
|
<member name="steering" type="float" setter="set_steering" getter="get_steering" default="0.0">
|
|
The steering angle for the vehicle, in radians. 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.
|
|
</member>
|
|
</members>
|
|
</class>
|