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...
PhysicsDirectBodyState3D
繼承: Object
被繼承: PhysicsDirectBodyState3DExtension
提供對 PhysicsServer3D 中物理體的直接存取。
說明
提供對 PhysicsServer3D 中物理體的直接存取,從而安全地更改物理屬性。該對象會在 RigidBody3D 的直接狀態回呼函式中傳遞,目的是為了改變物體的直接狀態。見 RigidBody3D._integrate_forces()。
教學
屬性
方法
屬性說明
物體的旋轉速度,單位為弧度每秒。
Vector3 get_center_of_mass()
該物體質心的位置,相對於該物體的中心,使用全域坐標系。
Vector3 center_of_mass_local 🔗
Vector3 get_center_of_mass_local()
該物體質心的位置,使用該物體的局部坐標系。
The body's collision layer.
The body's collision mask.
Vector3 get_inverse_inertia()
物體慣性的倒數。
Basis inverse_inertia_tensor 🔗
Basis get_inverse_inertia_tensor()
該物體慣性張量的倒數。
float get_inverse_mass()
物體品質的倒數。
物體的線速度,單位為單位每秒。
Basis principal_inertia_axes 🔗
Basis get_principal_inertia_axes()
There is currently no description for this property. Please help us by contributing one!
如果為 true,則該物體目前處於睡眠狀態(不活動)。
float get_step()
用於模擬的時間步長(delta)。
float get_total_angular_damp()
物體停止轉動的速度,如果沒有任何其他力使它運動。
Vector3 get_total_gravity()
這個物體上的總重力向量。
float get_total_linear_damp()
物體停止運動的速率,如果沒有任何其他力使它運動。
Transform3D transform 🔗
void set_transform(value: Transform3D)
Transform3D get_transform()
物體的變換矩陣。
方法說明
void add_constant_central_force(force: Vector3 = Vector3(0, 0, 0)) 🔗
在不影響旋轉的情況下,新增一個恒定的定向力,該力會隨著時間的推移而持續施加,直到使用 constant_force = Vector3(0, 0, 0) 清除。
這相當於在物體的質心處,使用 add_constant_force()。
void add_constant_force(force: Vector3, position: Vector3 = Vector3(0, 0, 0)) 🔗
向實體新增一個恒定的定位力,持續施加,直到用 constant_force = Vector3(0, 0, 0) 清除。
position 是在全域座標中距實體原點的偏移量。
void add_constant_torque(torque: Vector3) 🔗
在不影響位置的情況下,新增一個恒定的旋轉力,該力會隨著時間的推移而持續施加,直到使用 constant_torque = Vector3(0, 0, 0) 清除。
void apply_central_force(force: Vector3 = Vector3(0, 0, 0)) 🔗
施加一個不影響旋轉的定向力。該力是時間相關的,意味著每次物理更新都會施加。
這相當於在物體的質心處,使用 apply_force()。
void apply_central_impulse(impulse: Vector3 = Vector3(0, 0, 0)) 🔗
施加一個不影響的旋轉定向脈衝。
脈衝與時間無關!每影格套用一個脈衝,會產生一個依賴於畫面播放速率的力。出於這個原因,它應該只在模擬一次性影響時使用(否則使用 “_force”函式)。
這相當於在物體的質心處,使用 apply_impulse()。
void apply_force(force: Vector3, position: Vector3 = Vector3(0, 0, 0)) 🔗
對實體施加一個定位力。力是時間相關的,意味著每次物理更新都會被施加。
position 是在全域座標中距實體原點的偏移量。
void apply_impulse(impulse: Vector3, position: Vector3 = Vector3(0, 0, 0)) 🔗
向實體施加一個定位脈衝。
脈衝是時間無關的!每影格施加一個脈衝將產生一個依賴於畫面播放速率的力。出於這個原因,它應該只在模擬一次性影響時使用(否則使用“_force”函式)。
position 是在全域座標中距實體原點的偏移量。
void apply_torque(torque: Vector3) 🔗
在不影響位置的情況下,施加一個旋轉力。該力是與時間相關的,這意味著每次物理更新時都會被施加。
注意:inverse_inertia 是該函式生效所必需的。要擁有 inverse_inertia,一個活動的 CollisionShape3D 必須是該節點的子節點,或者可以手動設定 inverse_inertia。
void apply_torque_impulse(impulse: Vector3) 🔗
在不影響位置的情況下,向實體施加一個旋轉脈衝。
脈衝是時間無關的!每影格施加一個脈衝將產生一個依賴於畫面播放速率的力。出於這個原因,它應該只在模擬一次性影響時使用(否則使用“_force”函式)。
注意:inverse_inertia 是生效所必需的。要擁有 inverse_inertia,活動的 CollisionShape3D 必須是該節點的子節點,或者可以手動設定 inverse_inertia。
Vector3 get_constant_force() const 🔗
返回在每次物理更新期間,施加在該物體上的總恒定位置力。
見 add_constant_force() 和 add_constant_central_force()。
Vector3 get_constant_torque() const 🔗
返回在每次物理更新期間,施加在該物體上的總恒定旋轉力。
RID get_contact_collider(contact_idx: int) const 🔗
返回該碰撞體的 RID。
int get_contact_collider_id(contact_idx: int) const 🔗
返回該碰撞體的對象 id。
Object get_contact_collider_object(contact_idx: int) const 🔗
返回碰撞對象。
Vector3 get_contact_collider_position(contact_idx: int) const 🔗
返回該碰撞體上接觸點的位置,使用全域坐標系。
int get_contact_collider_shape(contact_idx: int) const 🔗
返回該碰撞體的形狀索引。
Vector3 get_contact_collider_velocity_at_position(contact_idx: int) const 🔗
返回該碰撞體接觸點處的線速度向量。
int get_contact_count() const 🔗
返回這個物體與其他物體的接觸次數。
注意:預設情況下,除非物體被設為監視接觸,否則會返回 0。見 RigidBody3D.contact_monitor。
Vector3 get_contact_impulse(contact_idx: int) const 🔗
由接觸產生的脈衝。
Vector3 get_contact_local_normal(contact_idx: int) const 🔗
返回接觸點處的局部法線。
Vector3 get_contact_local_position(contact_idx: int) const 🔗
返回該物體上接觸點的位置,使用全域坐標系。
int get_contact_local_shape(contact_idx: int) const 🔗
返回碰撞的局部坐標系下的形狀索引。
Vector3 get_contact_local_velocity_at_position(contact_idx: int) const 🔗
返回該物體上接觸點處的線速度向量。
PhysicsDirectSpaceState3D get_space_state() 🔗
返回空間的目前狀態,這對查詢很有用。
Vector3 get_velocity_at_local_position(local_position: Vector3) const 🔗
Returns the body's velocity at the given relative position.
local_position is the offset from the body origin in global coordinates.
void integrate_forces() 🔗
Updates the body's linear and angular velocity by applying gravity and damping for the equivalent of one physics tick.
void set_constant_force(force: Vector3) 🔗
設定在每次物理更新期間,施加在該物體上的總恒定位置力。
見 add_constant_force() 和 add_constant_central_force()。
void set_constant_torque(torque: Vector3) 🔗
設定在每次物理更新期間,施加在該物體上的總恒定旋轉力。