Material Box

Material Box

WEBデザイン & フリー素材

Godot - Nodeのタイプを判定する

Godot

if~is文でNodeのタイプを判定するGDScriptのコード例です。


GDScriptではif~is文でNodeのタイプを判定する事が可能です。

「Sprite2D」や「TileMap」など、Nodeのカテゴリ階層である「Node」「Node2D」でも一致する事に注意が必要です。

var node = get_node("Sprite2D")

if node is Sprite2D:
	print("target_nodeはSprite2Dです")
elif node is TileMap:
	print("target_nodeはTileMapです")

Godot

TitleGodot - Nodeのタイプを判定する

CategoryGodot

Created

Update

AuthorYousuke.U