無料で軽快なオープンソースのゲームエンジン GodotEngine4 の Godot Asset Library には、画像や音楽、スクリプトなどの様々な有料・無料のアセットが公開されています。

今回は、ウィザードリィ風の 3D ダンジョンを移動することができる無料のテンプレートアセット「DungeonCrawler3D」の導入、設定、実行までの手順を紹介します。
※ GodotEngine のバージョンは 4.2.1 です。 .NET 版ではありません。
※記事で紹介するスクリプト / プログラム / コードは自己責任で使用してください。
DungeonCrawler3D を実行するためのプロジェクトの作成
「DungeonCrawler3D」テンプレートアセットを GodotEngine4 エディタで実行するために、 GodotEngine プロジェクトマネージャーでプロジェクトを作成して、開きます。

アセットは、プロジェクトを開いた GodotEngine エディタの中央上部にある AssetLib ビュー内で、インストールできると思っていたのですが、なぜか DungeonCrawler3D アセットは表示されません。
※作成したプロジェクトの GodotEngine4 のバージョン 4.2 に対応しているアセットなのになぜか検索結果に出ません。

DungeonCrawler3D アセットのダウンロード
前述の理由からエディタ上で直接インポートはできなかったので、プロジェクトにいれる DungeonCrawler3D テンプレートアセットを公式サイト Godot Asset Library からダウンロードします。
Godot Asset Library にアクセスして、左上の検索ボックスで Dungeon などと入力すると表示される DungeonCrawler3D を選択します。

DungeonCrawler3D のページに移動したら Download ボタンを押してアセットをダウンロードします。

ダウンロードした zip ファイルを解凍して、作成した Godot プロジェクトのフォルダに追加・上書き保存します。
※「インポートプロセス — Godot Engine (4.x)の日本語のドキュメント」には、エディタのファイルシステムドックにファイル・フォルダをドラッグ&ドロップするやり方が書かれていますが、それを試すと .godot ファイルの更新を尋ねられたりしたので、上書き保存で追加しました。


プロジェクトのフォルダは、エディタのファイルシステムドックでトップにある res:// フォルダを右クリックして表示されるメニューから「ファイルマネージャ―で開く」を選択するとエクスプローラでそのフォルダが表示されます。

DungeonCrawler3D のための準備
プロジェクトのフォルダに追加・上書きした後に、エディタを開くと自動的にインポートが行われますが、以下のようにエラーメッセージが表示されます。
すべて Global という識別子を認識できないエラーです。
Godot Engine v4.2.1.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
modules/gltf/register_types.cpp:63 - プロジェクト設定でBlendファイルのインポートが有効になっていますが、エディターの設定でBlenderのパスが設定されていません。Blendファイルはインポートされません。
--- Debug adapter server started ---
--- GDScript language server started on port 6005 ---
res://Game/cell/cell.gd:11 - Parse Error: Identifier "Global" not declared in the current scope.
modules/gdscript/gdscript.cpp:2788 - Failed to load script "res://Game/cell/cell.gd" with error "Parse error". (User)
res://Game/World.gd:18 - Parse Error: Identifier "Global" not declared in the current scope.
res://Game/World.gd:18 - Parse Error: Identifier "Global" not declared in the current scope.
modules/gdscript/gdscript.cpp:2788 - Failed to load script "res://Game/World.gd" with error "Parse error". (User)
追加したファイルの中の Global.gd という gd スクリプトファイルの中に定義されている定数にアクセスできないことがエラーとして出力されています。

これは、DungeonCralwer3D をダウンロードしたページに書かれていた準備を行っていないからです。


DungeonCrawler3D の GitHub ページ「Rebelion-Board-game/DungonCrawler: port https://github.com/uheartbeast/3d-dungeon for Godot4」には、先ほどダウンロードしたページと同じように、使用方法などが書かれています。
DungeonCrawler: A Godot 4 Asset for Basic Dungeon Crawler Mechanics
DungeonCrawler is a valuable asset for Godot 4, designed to empower developers with fundamental dungeon crawler mechanics, including movement and dungeon generation. /n
This repository is a port of the original project hosted at uheartbeast/3d-dungeon tailored for Godot 4.DungeonCrawler は、Godot 4 の貴重な資産であり、移動やダンジョン生成などの基本的なダンジョン クローラー メカニズムを開発者に提供するように設計されています。 /n このリポジトリは、uheartbeast/3d-dungeon でホストされている元のプロジェクトを Godot 4 用に移植したものです。How to Run
- Incorporate “Global.gd” into the autoloader located at
Game/Global.gd
.- Launch “World.tscn”.
1. Game/Global.gd にあるオートローダーに「Global.gd」を組み込みます。
2.「World.tscn」を起動します。Dungeon Generation Guide
To generate a dungeon, utilize the tile map found at
Game/Map/map.tscn
.
Simply add any box to initiate the creation of a 3D dungeon cell (Game/cell/cell.tscn
).ダンジョンを生成するには、Game/Map/map.tscn にあるタイル マップを利用します。 任意のボックスを追加するだけで、3D ダンジョン セル (Game/cell/cell.tscn) の作成が開始されます。Rebelion-Board-game/DungonCrawler: port https://github.com/uheartbeast/3d-dungeon for Godot4 と Google 翻訳
説明に書かれているように、プロジェクトの設定を行います。
Global.gd の自動読み込み
「Rebelion-Board-game/DungonCrawler: port https://github.com/uheartbeast/3d-dungeon for Godot4」の説明に書かれているように、 Global.gd ファイルを自動読み込みに追加します。
Global.gd ファイルのパスをコピーします。
※ファイルシステムドックの Global.gd を右クリックして表示されるメニュー「パスをコピー」を選択します。

「プロジェクト設定」ウィンドウの「自動読み込み」タブを表示して、左上の「パス」テキストボックスに先ほどコピーした Global.gd ファイルのパスを貼り付けます。
※「プロジェクト設定」ウィンドウは、メニュー「プロジェクト」→「プロジェクト設定」で表示できます。
パスの隣にある「ノード名」テキストボックスにはファイル名と同じ Global と入力して右端の「追加」ボタンを押します。

以上で、 Global.gd ファイルを自動読み込みに追加できました。
エラー解消の確認
「Rebelion-Board-game/DungonCrawler: port https://github.com/uheartbeast/3d-dungeon for Godot4」の説明のとおりに Global.gd ファイルを自動読み込みに追加したら、エラーが解消したか確認しましょう。
さきほどは、赤く表示されていた cell.gd, world.gd スクリプトの Global という識別子が、赤くない文字色に変わりました。
エディタを再起動すると、エラーメッセージも表示されません。

テスト
「Rebelion-Board-game/DungonCrawler: port https://github.com/uheartbeast/3d-dungeon for Godot4」の説明のとおり、メインのシーンを World に切り替えます。
ファイルシステムドックで World.tscn ファイルをダブルクリックして、編集中のシーンを World に切り替えます。
※メインシーンは他にも「プロジェクト設定」ウィンドウで設定できます。

エディタの右上の「再生」ボタンまたは F5 キーを押すと、メインのシーンを実行します。

メインのシーンを設定していない場合は、現在編集中のシーンをメインにするかをたずねるダイアログが表示されるので「現在のものを選択」ボタンを押します。
.png)
DungeonCrawler3D のプロジェクトが実行されて、照明が反射する通路の壁が表示されました。


矢印キーで回転、前進、後退ができました。
まとめ
今回は、無料で軽快なオープンソースのゲームエンジン GodotEngine4 の Godot Asset Library で公開されている、ウィザードリィ風の 3D ダンジョンを移動することができる無料のテンプレートアセット「DungeonCrawler3D」の導入、設定、実行までの手順を紹介しました。
次回は、ダンジョンの形をタイルマップを使って編集(通路の追加)します。
参照サイト Thank You!
- Godot Engine – Free and open source 2D and 3D game engine
- Rebelion-Board-game/DungonCrawler: port https://github.com/uheartbeast/3d-dungeon for Godot4
- DungeonCrawler3D – Godot Asset Library
- Godot Asset Library
- Godot 4 で新しいタイルマップを使用する方法 – YouTube
記事一覧 → Compota-Soft-Press
コメント