Material Box

Material Box

WEBデザイン & フリー素材

Godot - 2つのノード間の距離を取得する

Godot

Godot 4でGDScriptを利用して2つのノード間の距離を取得する方法です。


distance_to()を利用して2つのノード間の距離を取得する事ができます。

distance_to()は以下の特徴があります。
・引数には対象のノードの位置を指定する
・position、global_positionが指定可能

var distance = global_position.distance_to(target.global_position)

Godot

TitleGodot - 2つのノード間の距離を取得する

CategoryGodot

Created

Update

AuthorYousuke.U