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.

CapsuleShape2D

繼承: Shape2D < Resource < RefCounted < Object

用於物理碰撞的 2D 膠囊形狀。

說明

2D 膠囊形狀,旨在用於物理學。通常用於為 CollisionShape2D 提供形狀。

效能:CapsuleShape2D 可以快速檢查碰撞,但比 RectangleShape2D 和 CircleShape2D 慢。

屬性

float

height

30.0

float

mid_height

float

radius

10.0


屬性說明

float height = 30.0 🔗

  • void set_height(value: float)

  • float get_height()

膠囊的總高度,包括半圓。

注意:膠囊的 height 必須至少為其 radius 的兩倍。否則,膠囊將變為圓形。如果 height 小於 radius 的兩倍,則屬性將調整為有效值。


float mid_height 🔗

  • void set_mid_height(value: float)

  • float get_mid_height()

膠囊的高度,不包括兩個半圓。這是膠囊中間矩形部分的高度,即兩個半圓圓心之間的距離。這是對 height 的封裝。


float radius = 10.0 🔗

  • void set_radius(value: float)

  • float get_radius()

膠囊的半徑。

注意:膠囊的 radius 不能大於其 height 的一半。否則,膠囊將變成圓形。如果 radius 大於 height 的一半,則屬性將調整為有效值。