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...
PhysicsBody3D
繼承: CollisionObject3D < Node3D < Node < Object
被繼承: CharacterBody3D, PhysicalBone3D, RigidBody3D, StaticBody3D
受物理影響的 3D 遊戲物件的抽象基底類別。
說明
PhysicsBody3D 與受物理影響的 3D 遊戲物件的抽象基底類別。所有 3D 物理體都繼承自這個類。
警告:縮放不均勻時,這個節點的行為可能不符合預期。建議讓所有軸上的縮放都保持一致,改為調整碰撞形狀的大小。
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
方法
void |
add_collision_exception_with(body: Node) |
get_axis_lock(axis: BodyAxis) const |
|
get_gravity() const |
|
move_and_collide(motion: Vector3, test_only: bool = false, safe_margin: float = 0.001, recovery_as_collision: bool = false, max_collisions: int = 1) |
|
void |
|
void |
set_axis_lock(axis: BodyAxis, lock: bool) |
test_move(from: Transform3D, motion: Vector3, collision: KinematicCollision3D = null, safe_margin: float = 0.001, recovery_as_collision: bool = false, max_collisions: int = 1) |
屬性說明
bool axis_lock_angular_x = false 🔗
鎖定物體在 X 軸上的旋轉。
bool axis_lock_angular_y = false 🔗
鎖定物體在 Y 軸上的旋轉。
bool axis_lock_angular_z = false 🔗
鎖定物體在 Z 軸上的旋轉。
bool axis_lock_linear_x = false 🔗
鎖定物體在 X 軸上的線性運動。
bool axis_lock_linear_y = false 🔗
鎖定物體在 Y 軸上的線性運動。
bool axis_lock_linear_z = false 🔗
鎖定物體在 Z 軸上的線性運動。
方法說明
void add_collision_exception_with(body: Node) 🔗
將一個物體新增到這個物體不能碰撞的物體列表中。
bool get_axis_lock(axis: BodyAxis) const 🔗
如果指定的線性或旋轉軸 axis 被鎖定,則返回 true。
Array[PhysicsBody3D] get_collision_exceptions() 🔗
返回該物體的碰撞例外節點陣列。
Returns the gravity vector computed from all sources that can affect the body, including all gravity overrides from Area3D nodes and the global world gravity.
KinematicCollision3D move_and_collide(motion: Vector3, test_only: bool = false, safe_margin: float = 0.001, recovery_as_collision: bool = false, max_collisions: int = 1) 🔗
沿著運動向量 motion 移動該物體。為了在 Node._physics_process() 和 Node._process() 中不依賴畫面播放速率,motion 應該使用 delta 計算。
發生碰撞後該物體就會停止運動。返回 KinematicCollision3D,包含停止時的碰撞信息,或者沿運動向量接觸到其他物體時的碰撞資訊。
如果 test_only 為 true,則該物體不會移動,但會給出可能的碰撞信息。
safe_margin 是用於碰撞恢復的額外邊距(詳見 CharacterBody3D.safe_margin )。
如果 recovery_as_collision 為 true,則恢復階段發生的穿透解除也會被報告為碰撞;例如,CharacterBody3D 在吸附到地板時會用這個選項來改善對地板偵測。
max_collisions 可用於檢索多次碰撞的結果。
void remove_collision_exception_with(body: Node) 🔗
將一個物體從該物體不能碰撞的物體列表中移除。
void set_axis_lock(axis: BodyAxis, lock: bool) 🔗
根據 lock 的值鎖定或解鎖指定的線性或旋轉軸 axis。
bool test_move(from: Transform3D, motion: Vector3, collision: KinematicCollision3D = null, safe_margin: float = 0.001, recovery_as_collision: bool = false, max_collisions: int = 1) 🔗
在不移動實體的情況下檢查碰撞。為了在 Node._physics_process() 或 Node._process() 中獨立於畫面播放速率,motion 應該使用 delta 來計算。
實際上是將節點的位置、縮放和旋轉設定為給定 Transform3D 的位置、縮放和旋轉,然後嘗試沿向量 motion 移動實體。如果碰撞會阻止實體沿整個路徑移動,則返回 true。
collision 是型別為 KinematicCollision3D 的一個可選物件,它包含有關停止時碰撞、或沿運動接觸另一個實體時碰撞的附加資訊。
safe_margin 是用於碰撞恢復的額外餘量(有關更多詳細資訊,請參閱 CharacterBody3D.safe_margin)。
如果 recovery_as_collision 為 true,恢復階段的任何穿透也將被報告為碰撞;這對於檢查該實體是否會接觸其他任意實體很有用。
max_collisions 允許檢索一個以上的碰撞結果。