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.

SpringArm3D

繼承: Node3D < Node < Object

能夠動態地將子節點朝碰撞點移動的 3D 射線投射。

說明

SpringArm3D 會朝它的 Z 軸投射射線或形狀,並將所有直接子節點朝碰撞點移動,可以保留一定的邊距。可用於第三人稱相機,讓其在狹窄空間中朝玩家移動(你可能需要在 SpringArm3D 的碰撞檢查中排除玩家的碰撞體)。

教學

屬性

int

collision_mask

1

float

margin

0.01

Shape3D

shape

float

spring_length

1.0

方法

void

add_excluded_object(RID: RID)

void

clear_excluded_objects()

float

get_hit_length()

bool

remove_excluded_object(RID: RID)


屬性說明

int collision_mask = 1 🔗

  • void set_collision_mask(value: int)

  • int get_collision_mask()

The layers against which the collision check will be done. See Collision layers and masks in the documentation for more information.


float margin = 0.01 🔗

  • void set_margin(value: float)

  • float get_margin()

進行碰撞偵測時,會給出 SpringArm3D 的一個候選長度。

然後將邊距減去該長度,並將該平移套用於該 SpringArm3D 的子物件。

當 SpringArm3D 有一個 Camera3D 作為子節點時,該邊距很有用:如果沒有邊距,該 Camera3D 將被放置在準確的碰撞點上;而有邊距時,該 Camera3D 將被放置在靠近碰撞點的地方。


Shape3D shape 🔗

用於該 SpringArm3D 的 Shape3D

當該形狀被設定後,SpringArm3D 將在其 z 軸上投射該 Shape3D,而不是執行一個射線投射。


float spring_length = 1.0 🔗

  • void set_length(value: float)

  • float get_length()

SpringArm3D 的最大範圍。這用作內部使用的射線和形狀投射的長度,以計算 SpringArm3D 子節點的所需位置。

要瞭解有關如何執行形狀投射或射線投射的更多資訊,請參閱 PhysicsDirectSpaceState3D 文件。


方法說明

void add_excluded_object(RID: RID) 🔗

將具有給定 RIDPhysicsBody3D 物件,新增到從碰撞檢查中排除的 PhysicsBody3D 對象列表中。


void clear_excluded_objects() 🔗

清空碰撞偵測排除 PhysicsBody3D 對象的列表。


float get_hit_length() 🔗

返回彈簧臂的目前長度。


bool remove_excluded_object(RID: RID) 🔗

從碰撞偵測排除 PhysicsBody3D 對象的列表中移除給定的 RID