Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
VehicleWheel3D
用於 VehicleBody3D 的 3D 物理體,能夠類比車輪的行為。
說明
作為 VehicleBody3D 子節點使用的節點,能夠模擬車輛其中一個車輪的行為。這個節點還充當了碰撞器,能夠偵測車輪是否與某個表面接觸。
注意:該類存在已知問題,並非旨在提供逼真的 3D 車輛物理效果。如果想要高級車輛物理,可能必須使用其他 PhysicsBody3D 類來編寫自己的物理整合函式。
教學
屬性
|
||
|
||
|
||
|
||
physics_interpolation_mode |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
get_contact_body() const |
|
get_contact_normal() const |
|
get_contact_point() const |
|
get_rpm() const |
|
get_skidinfo() const |
|
is_in_contact() const |
屬性說明
通過施加制動力使車輪減速。車輪只有在與表面接觸時才會減速。使車輛充分減速所需的力,取決於車輛的 RigidBody3D.mass。對於品質被設定為 1000 的車輛,嘗試使用 25 - 30 範圍內的值進行緊急制動。
float damping_compression = 0.83 🔗
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.
float damping_relaxation = 0.88 🔗
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 damping_compression property. For a damping_compression value of 0.3, try a relaxation value of 0.5.
通過施加引擎力使車輪加速。車輪只有在與表面接觸時才會加速。車輛的 RigidBody3D.mass 對車輛的加速度有影響。對於品質被設定為 1000 的車輛,請嘗試使用 25 - 50 範圍內的加速度值。
注意:模擬沒有考慮齒輪的影響,如果想要類比齒輪,需要為其新增邏輯。
負值將導致車輪倒轉。
車輪的轉向角,單位:弧度。將該屬性設定為非零值將導致車輛在移動時轉向。
float suspension_max_force = 6000.0 🔗
彈簧所能承受的最大力。該值應高於 VehicleBody3D 的 RigidBody3D.mass 的四分之一,否則該彈簧無法承載車輛的重量。大約 3 到 4 倍這個數字的值通常會獲得良好的結果。
float suspension_stiffness = 5.88 🔗
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.
float suspension_travel = 0.2 🔗
這是懸架可以移動的距離。由於Godot 的單位相當於米,所以保持這個設定相對較低。根據汽車的型別,試試 0.1 和 0.3 之間的值。
bool use_as_steering = false 🔗
如果為 true,當汽車轉向時這個輪子會轉動。該值與 VehicleBody3D.steering 結合使用,如果使用的是各個車輪的 steering 值,則該值將被忽略。
bool use_as_traction = false 🔗
如果為 true,該車輪會將引擎力傳遞到地面以推動車輛前進。該值與 VehicleBody3D.engine_force 結合使用,如果使用的是各個車輪的 engine_force 值,則該值將被忽略。
float wheel_friction_slip = 10.5 🔗
這決定了這個輪子的抓地力有多大。它與車輪所接觸的表面的摩擦力設定相結合。0.0 意味著沒有抓地力,1.0 是正常抓地力。對於漂移車的設定,嘗試將後輪的抓地力設定得比前輪略低,或者使用較低的數值來模擬輪胎的磨損。
在開始時最好將其設定為 1.0。
輪子的半徑,單位是米。
float wheel_rest_length = 0.15 🔗
這是輪子從原點下降的距離,以米為單位。不要把這個設定為 0.0,然後把車輪移到位置上,而是把車輪的原點(Godot 中的小工具)移到車輪觸底時的位置,然後使用剩餘長度將輪子向下移動到汽車靜止時它應該所處位置。
float wheel_roll_influence = 0.1 🔗
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.
方法說明
Node3D get_contact_body() const 🔗
如果接觸的實體節點在樹中有效,則返回接觸的實體節點,如 Node3D。目前,不支持 GridMap,因此該節點將始終為 PhysicsBody3D 型別。
如果車輪沒有與表面接觸,或者接觸的實體不是 PhysicsBody3D,則返回 null。
Vector3 get_contact_normal() const 🔗
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.
Vector3 get_contact_point() const 🔗
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.
返回輪子的旋轉速度,單位為每分鐘轉數。
返回一個介於 0.0 和 1.0 之間的值,表示這個輪子是否打滑。0.0 表示打滑(車輪失去了抓地力,例如冰雪地形),1.0 表示不打滑(車輪有充分的抓地力,例如乾燥的瀝青路)。
如果輪子與表面接觸,返回 true。