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.

WorldBoundaryShape2D

繼承: Shape2D < Resource < RefCounted < Object

用於物理碰撞的 2D 空間邊界(半平面)形狀。

說明

2D 世界邊界形狀,應當用於物理用途。WorldBoundaryShape2D 本質上和無限直線類似,能夠強制所有物理體都保持在它的上方。哪個方向是“上方”由該直線的法線確定,這個方向在編輯器中由直線上方的一條段線表示。用例是無限的平坦地面。

屬性

float

distance

0.0

Vector2

normal

Vector2(0, -1)


屬性說明

float distance = 0.0 🔗

  • void set_distance(value: float)

  • float get_distance()

從原點到直線的距離,沿 normal 方向(根據其方向和大小)。原點到直線實際距離的絕對值可以用 abs(distance) / normal.length() 計算。

在直線 ax + by = d 的標量方程中,這是 d,而 (a, b) 座標由 normal 屬性工作表示。


Vector2 normal = Vector2(0, -1) 🔗

The line's normal, typically a unit vector. Its direction indicates the non-colliding half-plane. Can be of any length but zero. Defaults to Vector2.UP.