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.

KinematicCollision2D

繼承: RefCounted < Object

存放移動 PhysicsBody2D 所產生的碰撞資料。

說明

存放移動 PhysicsBody2D 所產生的碰撞資料,通常是由 PhysicsBody2D.move_and_collide() 產生的。移動 PhysicsBody2D 時,它會在偵測到與另一個實體發生碰撞時停止。偵測到碰撞時就會返回 KinematicCollision2D 對象。

碰撞封包括碰撞物件、剩餘運動和碰撞位置。可以使用該資料進行碰撞的自訂響應。

方法

float

get_angle(up_direction: Vector2 = Vector2(0, -1)) const

Object

get_collider() const

int

get_collider_id() const

RID

get_collider_rid() const

Object

get_collider_shape() const

int

get_collider_shape_index() const

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


方法說明

float get_angle(up_direction: Vector2 = 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 🔗

返回移動物件的在碰撞前的運動。