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.

PathFollow3D

繼承: Node3D < Node < Object

Path3D 的點取樣器。

說明

這個節點接受它的父節點 Path3D 並返回其中一個點的座標,需要給定到第一個頂點的距離。

在不編碼移動圖案的情況下,它可以使其他節點遵循一條路徑。為此,節點必須是該節點的子節點。在該節點中設定 progress 後,後代節點會隨之移動。

屬性

bool

cubic_interp

true

float

h_offset

0.0

bool

loop

true

float

progress

0.0

float

progress_ratio

0.0

RotationMode

rotation_mode

3

bool

tilt_enabled

true

bool

use_model_front

false

float

v_offset

0.0

方法

Transform3D

correct_posture(transform: Transform3D, rotation_mode: RotationMode) static


列舉

enum RotationMode: 🔗

RotationMode ROTATION_NONE = 0

禁止該 PathFollow3D 旋轉。

RotationMode ROTATION_Y = 1

允許該 PathFollow3D 僅在 Y 軸上旋轉。

RotationMode ROTATION_XY = 2

允許該 PathFollow3D 同時在 X 和 Y 軸上旋轉。

RotationMode ROTATION_XYZ = 3

允許該 PathFollow3D 在任意軸上旋轉。

RotationMode ROTATION_ORIENTED = 4

使用 Curve3D 中的向上向量資訊來強制定向。該旋轉模式需要將 Path3DCurve3D.up_vector_enabled 屬性設定為 true


屬性說明

bool cubic_interp = true 🔗

  • void set_cubic_interpolation(value: bool)

  • bool get_cubic_interpolation()

如果為 true,則兩個快取點之間的位置將被三次插值,否則將被線性插值。

沿著 Path3DCurve3D 的點在使用前已被預先計算,以便更快地計算。然後在兩個相鄰快取點之間,插值計算請求的偏移處的點。如果曲線急轉彎,這可能會出現問題,因為快取的點可能沒有足夠緊密地跟隨曲線。

這個問題有兩個答案:要麼增加快取點的數量,並增加記憶體消耗;要麼在兩個點之間進行三次插值,代價是(稍微)降低計算速度。


float h_offset = 0.0 🔗

  • void set_h_offset(value: float)

  • float get_h_offset()

節點沿曲線的偏移量。


bool loop = true 🔗

  • void set_loop(value: bool)

  • bool has_loop()

如果為 true,路徑長度以外的任何偏移都將環繞,而不是在結束時停止。對於迴圈路徑使用它。


float progress = 0.0 🔗

  • void set_progress(value: float)

  • float get_progress()

到第一個頂點的距離,單位為沿路徑經過的 3D 單位數。改變這個值會將這個節點的位置設定為路徑上的某個點。


float progress_ratio = 0.0 🔗

  • void set_progress_ratio(value: float)

  • float get_progress_ratio()

The distance from the first vertex, considering 0.0 as the first vertex and 1.0 as the last. This is just another way of expressing the progress within the path, as the progress supplied is multiplied internally by the path's length.

It can be set or get only if the PathFollow3D is the child of a Path3D which is part of the scene tree, and that this Path3D has a Curve3D with a non-zero length. Otherwise, trying to set this field will print an error, and getting this field will return 0.0.


RotationMode rotation_mode = 3 🔗

允許或禁止在一個或多個軸上旋轉,這取決於使用的 RotationMode 常數。


bool tilt_enabled = true 🔗

  • void set_tilt_enabled(value: bool)

  • bool is_tilt_enabled()

如果為 true,則 Curve3D 的傾斜屬性生效。


bool use_model_front = false 🔗

  • void set_use_model_front(value: bool)

  • bool is_using_model_front()

如果為 true,則沿路徑移動的節點會將 +Z 軸作為前方向進行朝向。另見 Vector3.FORWARDVector3.MODEL_FRONT


float v_offset = 0.0 🔗

  • void set_v_offset(value: float)

  • float get_v_offset()

節點垂直於曲線的偏移量。


方法說明

Transform3D correct_posture(transform: Transform3D, rotation_mode: RotationMode) static 🔗

校正 transformrotation_mode 隱式指定如何計算姿勢(向前、向上和側向)。