跳转至

Physics2DDirectBodyState

继承

Object

简要描述

将对象直接访问Physics2DServer中的物理主体。

描述

可直接访问Physics2DServer中的物理实体,从而可以安全地更改物理属性。

成员

类型 属性名 默认值
float angular_velocity
float inverse_inertia
float inverse_mass
Vector2 linear_velocity
bool sleeping
float step
float total_angular_damp
Vector2 total_gravity
float total_linear_damp
Transform2D transform

方法

返回值类型 方法名称
void add_central_force(force: Vector2)
void add_force(offset: Vector2, force: Vector2)
void add_torque(torque: float)
void apply_central_impulse(impulse: Vector2)
void apply_impulse(offset: Vector2, impulse: Vector2)
void apply_torque_impulse(impulse: float)
RID get_contact_collider(contact_idx: int) const
int get_contact_collider_id(contact_idx: int) const
Object get_contact_collider_object(contact_idx: int) const
Vector2 get_contact_collider_position(contact_idx: int) const
int get_contact_collider_shape(contact_idx: int) const
Variant get_contact_collider_shape_metadata(contact_idx: int) const
Vector2 get_contact_collider_velocity_at_position(contact_idx: int) const
int get_contact_count() const
Vector2 get_contact_local_normal(contact_idx: int) const
Vector2 get_contact_local_position(contact_idx: int) const
int get_contact_local_shape(contact_idx: int) const
Physics2DDirectSpaceState get_space_state()
void integrate_forces()

常量

成员说明

  • float angular_velocity
setter set_angular_velocity(value)
getter get_angular_velocity
  • float inverse_inertia
getter get_inverse_inertia
  • float inverse_mass
getter get_inverse_mass
  • Vector2 linear_velocity
setter set_linear_velocity(value)
getter get_linear_velocity
  • bool sleeping
setter set_sleep_state(value)
getter is_sleeping
  • float step
getter get_step
  • float total_angular_damp
getter get_total_angular_damp
  • Vector2 total_gravity
getter get_total_gravity
  • float total_linear_damp
getter get_total_linear_damp
  • Transform2D transform
setter set_transform(value)
getter get_transform

方法说明

  • add_central_force add_central_force(force: Vector2)

在不影响旋转的情况下增加恒定的方向力。


  • add_force add_force(offset: Vector2, force: Vector2)

向身体添加定位力。力和相对于身体原点的偏移都在全局坐标中。


  • add_torque add_torque(torque: float)

增加恒定的旋转力。


  • apply_central_impulse apply_central_impulse(impulse: Vector2)

在不影响旋转的情况下施加方向性脉冲。


  • apply_impulse apply_impulse(offset: Vector2, impulse: Vector2)

向身体施加定位脉冲。脉冲是与时间无关的!每帧施加一个脉冲将导致依赖于帧速率的力。因此,仅在模拟一次性冲击时才应使用它(否则请使用“ _force”功能)。偏移使用全局坐标系的旋转,但以对象的原点为中心。


  • apply_torque_impulse apply_torque_impulse(impulse: float)

向身体施加旋转脉冲。


  • get_contact_collider get_contact_collider(contact_idx: int) const

返回对撞机的RID


  • get_contact_collider_id get_contact_collider_id(contact_idx: int) const

返回对撞机的对象ID。


  • get_contact_collider_object get_contact_collider_object(contact_idx: int) const

返回碰撞对象。


  • get_contact_collider_position get_contact_collider_position(contact_idx: int) const

返回碰撞中的接触位置。


  • get_contact_collider_shape get_contact_collider_shape(contact_idx: int) const

返回碰撞的形状索引。


  • get_contact_collider_shape_metadata get_contact_collider_shape_metadata(contact_idx: int) const

返回碰撞的形状的元数据。


  • get_contact_collider_velocity_at_position get_contact_collider_velocity_at_position(contact_idx: int) const

返回对撞机接触点处的线速度矢量。


  • get_contact_count get_contact_count() const

返回此实体与其他实体的联系数。

**注意:**默认情况下,除非将该实体配置为监视联系人,否则它返回0。请参阅RigidBody2D.contact_monitor


  • get_contact_local_normal get_contact_local_normal(contact_idx: int) const

返回接触点的局部法线。


  • get_contact_local_position get_contact_local_position(contact_idx: int) const

返回接触点的本地位置。


  • get_contact_local_shape get_contact_local_shape(contact_idx: int) const

返回碰撞的局部(local)形状索引。


  • get_space_state get_space_state()

返回空间的当前状态,对查询很有用。


  • integrate_forces integrate_forces()

调用内置的强制集成代码。