当前位置:网站首页>[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】
目录
2 Use a static platform:TileMap
3 Use dynamic platforms:MovingPlatform
3.2 Customize the movement path Add Node
4 Create more complex interactions:The pressure plate mechanism opens the door
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的方法.
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游戏制作.
边栏推荐
- MySQL optimization strategy
- Handwritten Blog Platform ~ Day Two
- 菜刀webshell特征分析
- Centos7 install postgresql and enable remote access
- Project Background Technology Express
- "NetEase Internship" Weekly Diary (2)
- 力扣、752-打开转盘锁
- MySQL - CRUD operations
- [ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)
- Service discovery of kubernetes
猜你喜欢

永磁同步电机36问(二)——机械量与电物理量如何转化?

A good book for newcomers to the workplace

Check if IP or port is blocked

From 2023 onwards, these regions will be able to obtain a certificate with a score lower than 45 in the soft examination.

Ringtone 1161. Maximum In-Layer Elements and

Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products

MySQL optimization strategy

Outsourcing worked for three years, it was abolished...

Redis 底层的数据结构

项目后台技术Express
随机推荐
十字光标太小怎么调节、CAD梦想画图算量技巧
nacos startup error, the database has been configured, stand-alone startup
MySQL optimization strategy
Analysis of the status quo of digital transformation of manufacturing enterprises
[ORB_SLAM2] SetPose, UpdatePoseMatrices
2023年起,这些地区软考成绩低于45分也能拿证
Rasa 3 x learning series - Rasa - 4873 dispatcher Issues. Utter_message study notes
Centos7 安装postgresql并开启远程访问
Speed up your programs with bitwise operations
libcurl访问url保存为文件的简单示例
【LeetCode每日一题】——704.二分查找
Handwriting a blogging platform ~ Day 3
Unable to log in to the Westward Journey
记一次gorm事务及调试解决mysql死锁
2022河南青训联赛第(三)场
记一个gorm初始化的坑
AOF rewrite
Coding Experience Talk
拼多多借力消博会推动国内农产品品牌升级 看齐国际精品农货
LeetCode Brushing Diary: 74. Searching 2D Matrix