LoginSignup
15
11

More than 5 years have passed since last update.

ダンジョンを作れる!TerrainTileを使ってみよう!

Last updated at Posted at 2018-01-24

 UnityのTilemapの公式拡張コード群「2d-extras」の中のコードの一つ、TerrainTileを紹介します。

TerrainTileとは?

 TerrainTileTilemapの拡張スクリプト、ScriptableTileの一つです。

 このTerrainTileを活用することで、次のGif画像のようなダンジョンを非常に簡単に作ることができます。

 壁や床ごとに異なるTileを配置する必要はありません。たった一つのTerrainTileを使うだけでOKです。

 便利でしょ?すごいでしょ?

terrain.gif

TerrainTileを作るには

 TerrainTileを作成する手順は次の通りです。

  1. 2d-extrasをプロジェクトにいれる
  2. Assets > Create > Terrain TileからTerrainTileScriptableObjectを生成する
  3. 15種の画像を適切に用意し設定する

 TerrainTileは次の画像のように、インスペクターから画像を設定する必要があります。適切に画像を設定しないと想定通りの挙動をしてくれません。

キャプチャ.PNG

 設定する15種の画像は次の通りです。

filled.png Filled 四方向の壁すべてが埋まっている画像です。 

three_sides.png Three Sides 3方向の壁で、上方向が空いている画像です。

two_sides_and_one_corner.png Two Sides and One Corner 下と左が壁で、右斜め上の角のブロックがある画像です。

two_adjacent_sides.png Two Adjacent Sides 下と左が壁の画像です。

two_opposite_sides.png Two Opposite Sides 左と右が壁の画像です。

one_side_and_two_corners.png One Side and Two Corners 左が壁で、右斜め上の角と右斜め下の角にブロックがある画像です。

one_side_and_one_lower_corner.png One Side and One Lower Conrner 左が壁で、右斜め下の角にブロックがある画像です。

one_side_and_one_upper_corner.png One Side and One Upper Conrner 左が壁で、右斜め上の角にブロックがある画像です。

one_side.png One Side 左が壁の画像です。

four_corners.png Four Corners 四隅の角にブロックがある画像です。

three_corners.png Three Corners 左斜め上の角・左斜め下の角・右斜め下の角にブロックがある画像です。

two_adjacent_corners.png Two Adjacent Corners 左斜め上の角と左斜め下の角にブロックがある画像です。

two_opposite_corners.png Two Oppsite Corners 左斜め上の角と右斜め下の角にブロックがある画像です。

one_corner.png One Corner 左斜め上の角にブロックがある画像です。

empty.png Empty 壁もブロックもない画像です。

TerrainTileで作ろうダンジョン

 このようにTerrainTileを用いれば非常に手早くダンジョンを作れます!

 みんなもダンジョン、作ろうぜ!

15
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
11