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()
该物体质心的位置,使用该物体的局部坐标系。
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()
该属性目前没有描述,请帮我们贡献一个吧!
如果为 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 🔗
返回给定相对位置的物体速度,包括平移和旋转。
void integrate_forces() 🔗
通过应用相当于一个物理刻度的重力和阻尼来更新物体的线速度和角速度。
void set_constant_force(force: Vector3) 🔗
设置在每次物理更新期间,施加在该物体上的总恒定位置力。
见 add_constant_force() 和 add_constant_central_force()。
void set_constant_torque(torque: Vector3) 🔗
设置在每次物理更新期间,施加在该物体上的总恒定旋转力。