当前位置:网站首页>[Unity entry plan] 2D Game Kit: A preliminary understanding of the composition of 2D games

[Unity entry plan] 2D Game Kit: A preliminary understanding of the composition of 2D games

2022-08-02 02:16:00 flashinggg

目录

项目前期准备

Import game assets

RuleTilefile outbug

1 利用Kit Tools添加新场景

2 Use a static platform:TileMap

2.1 打开Tile Palette

2.2 添加Tile

3 Use dynamic platforms:MovingPlatform

3.1 移动方式 Platform Type

3.2 Customize the movement path Add Node

4 Create more complex interactions:The pressure plate mechanism opens the door

4.1 Add an organ object1:压力板

4.2 Add an organ object2:门

5 加入敌人

6 Implement indirect attacks:推箱子

7 Realize the transfer of characters


项目前期准备

Import game assets

学习基于Unity官方提供的2D Game Kit项目资源,链接如下 

2D Game Kit | 教程 | Unity Asset Store

Save to mine

 资源在UnityJust load it and import it. 

RuleTilefile outbug

Appeared after opening the projectRuleTile相关的bug,可以参考教程P47的改bug的方法.

【unity2021入门教程】47-2DGame Development Tutorial Series-02-2DGameKit-01-Introduction and modificationbug_哔哩哔哩_bilibili


1 利用Kit Tools添加新场景

利用导入的Creator Kit创建的Kit Toolsmenu to create a new scene,命名为MyScene

Observe the scene grouping

2 Use a static platform:TileMap

官方手册:Unity - Manual: Tilemap (unity3d.com)

TileMapProvides users with a quick way to create a game platform,With simple movements, a platform can be built that can host gamers,It has components such as rigid bodies.

作为一个Unity学习的新手,The sooner you get started and make your own level, the more satisfaction you will get!在跟着B站UPThis tool is covered in the tutorial,觉得挺有意思的,先简单的使用一下,Will study later.

2.1 打开Tile Palette

2.2 添加Tile

It is very convenient to operate

  • 添加:选择想要的tile网格,在SceneMiddle left click to add
  • 移动:Right click to move the scene
  • 删除:按住ShiftAdded ones can be quickly erasedtile

It will also autocompletetileconnecting part between! 

3 Use dynamic platforms:MovingPlatform

游戏中,Except for some static ones、Fixed only provide load bearing、Platform for mobile action,Some mobile platforms are also required,Kit ToolSuch a dynamic platform is also included in the created scene.

Assets -> Prefabs -> Interactables -> MovingPlatform/MovingPlatformlong,Drag prefabs into the scene to create mobile platforms,Contains a script primarily used to control the platformMoving Platform Script,以及其他组件.

3.1 移动方式 Platform Type

This is how the platform moves,There are the following three

  • Back_Forth:前后移动
  • LOOP:循环移动
  • ONCE:移动一次 

3.2 Customize the movement path Add Node

添加的这些Nodes和Preview positiontogether to form a movement trajectory,Can be a single platform that moves back and forth,It can also be a platform that moves circularly in a quadrilateral.

4 Create more complex interactions:The pressure plate mechanism opens the door

这里用到了PressurePadSuch a pressure plate preform,Realize the interaction effect between game objects that open the door after stepping on it.

Assets -> Prefabs -> Interactables -> PressurePad,Double click to view the prefab,It can be seen that the appearance is a platform.

由几个组件组成,There are also sound components,其中主要是PressurePadScript component to control.

4.1 Add an organ object1:压力板

Drag one into the scene,观察这个PressurePad,他有一个Box碰撞体属性,意味着这个boxOnly within the range can his pedaling interaction be realized,This range can be adjusted to avoid situations where the position is too close to the lawn to trigger the trigger.

4.2 Add an organ object2:门

Asserts ->  Prefabs -> Interactables -> Door,Drag into the scene to add the door.

Also need to associate the door and pedal mechanism,在PressurePad的Pressure PadScript componentOn Pressed()Associated with the added door and the door's opening animation.,The door can be opened after stepping on the pedal.

5 加入敌人

In addition to the game object controlled by the player in the game,还需要有“敌人”,to enrich the game,2D Game Kit提供了EnemiesResources for us to learn.

Each enemy hangs some components,One of the main enemy actions is scriptedEnemy Behaviour控制.

The script also visualizes the enemy's visual range and attack range. 

6 Implement indirect attacks:推箱子

Also provided in the projectPushableBoxThe operation of pushing down and smashing the enemy from a height.

加入一个PushableBox到场景中,It also consists of many components.

Here we focus on threeBox Collider 2D碰撞体组件:

The three hanging colliders are implemented separately

  • Push the box from the right
  • Push the box from the left
  • Can't go through boxes 

 To turn boxes into weapons,Also hang a victim script,将Hittable Layer改成enemy

7 Realize the transfer of characters

Scene teleportation provides some actionable objects,implement the same scenario、Jump between two scenes.

For example the project provides oneTransitionStar,Achieve both by changing his componentTransition之间的转换. 


The above is to follow the tutorial2D Game Kit项目的学习,But this is already a complete project,Just did the prefab learning,The following will follow the tutorial to continue learning2D游戏制作. 

原网站

版权声明
本文为[flashinggg]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/214/202208020211021244.html