Article directory
1) User guide
①Foreword
The complete development process of this project has written detailed tutorial documents in the teaching documents of the official Unity project , but because the official documents have been away for a while, there are errors in some places or the readers are using the Unity editor on their own machines. In the process of operation, I still encountered scattered problems, which can no longer correspond to the official tutorial. This blog is a supplement to the projects provided by the official website, as well as personal review and experience sharing.
This series of blogs is derived from the official tutorial, but it will definitely be higher than the official tutorial in the end, allowing readers to integrate the official tutorial and my own sublimation, and be able to independently develop a more complete and feasible game than the official tutorial.
The final development results and resources will also be open sourced on GitHub and Gitee.
This series of blogs is derived from the official tutorial, but it will definitely be higher than the official tutorial in the end, allowing readers to integrate the official tutorial and my own sublimation, and be able to independently develop a more complete and feasible game than the official tutorial.
The final development results and resources will also be open sourced on GitHub and Gitee.
②Official Tutorial
[ Official Documents - 4. World Design - Tile Map ]
[ Official Documents - 5. Decorate the World ]
③How to deal with the relationship between this series of blogs and official tutorials
My personal suggestion is to first browse the blogs of this series of columns, get a preliminary impression of the precautions and key points, and then follow the official documents to operate step by step.
Because this series of blogs is a revision, supplement, and sublimation of the official tutorial, and the content of this series of blogs will not be particularly lengthy, it will take about 5-7 minutes to read it completely.
If you only look at the content of the article and pay attention to the places that need to be corrected, it will only take about 1 minute.
2) Detailed analysis of specific steps
Front row warm reminder: Official tutorial - 4. In the world design - tile map tutorial, except for the second step of creating a tile map and the third step of creating a new tile, an update operation is required.
Others can be done completely according to the official tutorial, and the teaching logic of the official tutorial is very clear.
2.1) "4-2. Create tile map" operation update
The content given in the official website tutorial document is the page displayed by the Unity editor before 2020.3 when creating a tile map. Maybe many friends who use the latest version of the editor will feel confused when they read the document, and have a strong sense of persuasion.
Official tutorial operation diagram:
Now you can follow my steps and re-learn how to create a tile map in the Unity editor after version 2020.3.
Corrected operation diagram:
The result created is consistent with what is described in the tutorial, here you can by the way know one for rules and management of tile maps Gird 对象
, as well as for drawing game maps in the grid rangeTilemap 对象
Extended extension
① Rectangler rectangular tile map
In the former Unity editor, it is said that creating a tile map is a Rectangular
rectangular tile map selected by default
② Hexagonal hexagonal tile map
As for and are and respectivelyHexagonal - Pointed - Top
. Hexagonal tiles are often used in strategy tabletop games ③ Isometric isometric tile maps: An isometric perspective view shows all three X, Y and Z axes, so pseudo depth and height can be added to tile maps. Isometric tile maps are often used in strategy games because an isometric perspective allows simulating 3D game elements such as different elevations and line of sight. This allows players to make tactical decisions about movement and positioning during gameplay. An article about the isometric perspective by Shanghai Bear Soul Network Technology Co., Ltd. in Zhihu is very well written, and you can refer to it for reference. [Unity] Use Tilemap to create a 2D environment for isometric perspective (Isometric)Hexagonal - Flat- Top
六边形瓦片地图点朝上
六边形瓦片地图边朝上
2.2) "4-3. Create a new tile" operation update
The tile map has been created, so all you need at this point is the tiles to fill the map. Let's first systematically understand what a tile is.
Tiles are assets arranged on a tile map to build a 2D environment. Each tile references a selected sprite, which is then rendered at the tile location on the tilemap grid.
Tile | The version after 2020.3 has not been seen. As for the use, it has not been fixed for the time being. |
---|---|
Scriptable Tile | self programming tiles |
Rule Tile | Rule tiles, that is, you can define the generation rules of tiles yourself |
Animated Tile | animated tiles |
Because of the version after 2020.3, Tile is not directly provided for use, so the diagram provided in the fourth step of "3. Create a new tile" needs to be updated. 规则瓦片
The newer idea is to replace normal tiles with ones that don't hook into any specs .
The specific operation can follow the following figure:
If 2D目录
you don't have Tiles目录
it, you can refer to this article to solve it:
[Trivial and trivial knowledge] About the lack of Tiles options when creating tile maps in some Unity editors
Small suggestion: It is recommended to put three folders under the Tiles folder
① DefaultTiles stores tiles that only cut the tile set but do not add any generation rules, which will be used here when adding colliders to the Tilemap later.
② Palettes store GamePalette artboards
③ RuleTiles Store rule tiles with set generation rules
2.3) 《5-2. How can we solve the sorting problem? 》Operation Note
The main purpose of this operation is to shape 伪透视
the feeling. That is , intuitively, the character is drawn first when the character is in front of the cube, and the cube is drawn first when the character is behind the cube.
If the sorting is not adjusted to create a false perspective, a situation similar to the following picture will appear, which does not seem to be in line with real life.
The specific method of creating pseudo-perspective starts from step 3 and ends at step 6, all of which are about the solution to this problem.
By adjusting the sprite control order,
Sprite Sort Point 字段
it is sorted according to the axisPivot
, and thenPivot字段
adjust the axis of the specific sprite to the bottomBottom
. Finally, the pseudo-perspective effect of the following figure can be achieved.
If this kind of production is required for each game object, the development efficiency will be very slow. In order to facilitate us to be lazy , in order to facilitate our development, we will make the tree that has just been set up as a prefab, which can be set at one time. Used many times to achieve once and for all.
2.3) 《5-7. What is a prefab? 》Operation accumulation
The operation of making prefabs is relatively simple, just reminding the accumulation, because it is very useful...
Make it once, CV many times
3) Create map operation extension
3.1) Preface to regular tile usage
According to the method in the tutorial, you can indeed create all kinds of tile maps, but whether you have developed it, this method is a bit like every tile needs to be laid by ourselves. If the map of the game is very large, then the workload It's actually kind of scary.
Unity actually supports writing the Tile classes you need with code, which is the one in the table above Scriptable Tile 自编程瓦片
.
For example, a tile can be customized to be able to fill a grid with 20 units of up, down, left, and right as tiles. In the same way, Unity also supports creating its own Brush class to design grid brushes suitable for its own game.
However, for our current level, it is a bit difficult. The more humane part of Unity is that it also provides a graphical programming method for us who are relatively lacking in ability to meet the rules that we stipulate that a certain tile can generate other tiles up, down, left, and right. .
3.2) The use of regular tiles
This time, we will start with the basic usage of rule tiles. The rule definition of rule tiles will be carried out according to the generation rules of tiles in the tile set.
For example, the tile in the upper left corner of the tile set will have tiles below and to the right, so when defining the rules, it also conforms to the situation in the tile set.
① Create a specified folder to place rule tiles
. For example, I create a RuleTiles folder under the Tiles folder responsible for placing tile resources, which is specially used to store the rule tiles I define.
② Create a rule tile and name it RuleTile1
③ Click RuleTiles1 to manipulate the Tiling Rules for adding rules
④ According to the actual situation of a tile sprite in the tile set, define the logic of the tiles that appear around
it. select 瓦片集经过拆分之后的瓦片精灵
.
⑤ Specify the logic of each tile sprite
⑥ Drag the defined RuleTile1 into the Pallate
For those who want to see the original document, you can take a look at the official tutorial:
Using Rule Tiles
3.3) Rules cover the use of tiles
There may be some friends who feel that they have unlocked the new world and are already eager to deal with the other five tile sets. People want to do the least thing with the least amount of time, so this Unity editor can really satisfy us…
Rule overlay tiles offer two options in the Unity editor.
①Rule Override Tile
Rule Override Tile will completely copy the rules of the original Rule Tile provided.
However, after overwriting, I cannot modify my own rules. For example, I want the tile in the upper left corner of the tile set to be set to a non-passable state on a whim, and I cannot adjust it at this time.
1. Create a Rule Override Tile - similar to creating a Rule Tile
2. Add the Rule Tile that you want to copy the rules to
in the Tile 3. Add the tile set sprite you want to copy the rules to
in the Tile 4. Add the created rule tile to the Tile Palette piece
②Advanced Rule Override Tile
Advanced Rule Override Tile can not only be copied completely, but also can be modified by yourself, which is too intimate.
1. Create Advanced Rule Override Tile - similar to creating
Rule
Tile
In fact, it is not necessary to completely customize the rules according to the tile set, you can also play splicing ~
the rest of the content is completely implemented according to the official tutorial.
4) Summary
① Create a tile map and create a tile (tile map - step 2 to step 6)
② Create rule tiles, define the generation rules
③ Understand the logic of rule overlay tile usage
④ The need for pseudo perspective depends on changing graphics settings and Adjust the wizard axis (decoration world - step 2 to step 6)
⑤ Adjust the axis and understand the role of the axis
⑥ Production of prefabs (decoration world - step 7 to step 9)
The production of game maps may occupy 50% to 60% of the workload of the entire game project. In 2D games, flexible use 规则瓦片
is very important. But now you can basically master how to draw. As for the general map of the entire game, it is recommended to learn the collider in the next section and then draw it systematically.