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...
KinematicCollision2D¶
继承: RefCounted < Object
存放移动 PhysicsBody2D 所产生的碰撞数据。
描述¶
存放移动 PhysicsBody2D 所产生的碰撞数据,通常是由 PhysicsBody2D.move_and_collide 产生的。移动 PhysicsBody2D 时,它会在检测到与另一个实体发生碰撞时停止。检测到碰撞时就会返回 KinematicCollision2D 对象。
碰撞数据包括碰撞对象、剩余运动和碰撞位置。可以使用该数据进行碰撞的自定义响应。
方法¶
get_collider ( ) const |
|
get_collider_id ( ) const |
|
get_collider_rid ( ) const |
|
get_collider_shape ( ) const |
|
get_collider_shape_index ( ) const |
|
get_collider_velocity ( ) const |
|
get_depth ( ) const |
|
get_local_shape ( ) const |
|
get_normal ( ) const |
|
get_position ( ) const |
|
get_remainder ( ) const |
|
get_travel ( ) const |
方法说明¶
float get_angle ( Vector2 up_direction=Vector2(0, -1) ) const
根据 up_direction
返回碰撞角度,up_direction
默认为 Vector2.UP。该返回值始终为正。
Object get_collider ( ) const
返回该碰撞实体所附加的 Object。
int get_collider_id ( ) const
返回该碰撞物体附加的 Object 的唯一实例 ID。见 Object.get_instance_id。
RID get_collider_rid ( ) const
返回 PhysicsServer2D 使用的碰撞物体的 RID。
Object get_collider_shape ( ) const
返回该碰撞物体的形状。
int get_collider_shape_index ( ) const
返回该碰撞物体形状的索引。见 CollisionObject2D。
Vector2 get_collider_velocity ( ) const
返回该碰撞物体的速度。
float get_depth ( ) const
返回该碰撞物体沿碰撞法线覆盖的长度。
Object get_local_shape ( ) const
返回移动对象的碰撞形状。
Vector2 get_normal ( ) const
返回该碰撞物体的形状在碰撞点的法线。
Vector2 get_position ( ) const
返回碰撞点,使用全局坐标。
Vector2 get_remainder ( ) const
返回移动对象的剩余移动向量。
Vector2 get_travel ( ) const
返回移动对象的在碰撞前的运动。