当前位置:网站首页>[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游戏制作.
边栏推荐
- LeetCode Brushing Diary: 74. Searching 2D Matrix
- 用位运算为你的程序加速
- LeetCode brushing diary: 33. Search and rotate sorted array
- Redis for distributed applications in Golang
- 『网易实习』周记(二)
- LeetCode刷题日记:53、最大子数组和
- ALCCIKERS Shane 20191114
- 检查IP或端口是否被封
- Electronic Manufacturing Warehouse Barcode Management System Solution
- nacos startup error, the database has been configured, stand-alone startup
猜你喜欢
LeetCode刷题日记:74. 搜索二维矩阵
oracle query scan full table and walk index
雇用WordPress开发人员:4个实用的方法
LeetCode Brushing Diary: 74. Searching 2D Matrix
永磁同步电机36问(三)——SVPWM代码实现
Unable to log in to the Westward Journey
Analysis of volatile principle
Reflex WMS Intermediate Series 7: What should I do if I want to cancel the picking of an HD that has finished picking but has not yet been loaded?
Handwritten Blog Platform ~ Day Two
Redis 订阅与 Redis Stream
随机推荐
FOFAHUB使用测试
AOF rewrite
A good book for newcomers to the workplace
Constructor instance method inheritance of typescript37-class (extends)
垃圾回收器CMS和G1
2022河南青训联赛第(三)场
项目后台技术Express
Handwritten Blog Platform ~ Day Two
2022-08-01 安装mysql监控工具phhMyAdmin
Ringtone 1161. Maximum In-Layer Elements and
Fly propeller power space future PIE - Engine Engine build earth science
【LeetCode每日一题】——704.二分查找
LeetCode brush diary: LCP 03. Machine's adventure
Chengdu openGauss user group recruit!
Safety (2)
The Paddle Open Source Community Quarterly Report is here, everything you want to know is here
使用docker安装mysql
雇用WordPress开发人员:4个实用的方法
AI目标分割能力,无需绿幕即可实现快速视频抠图
"NetEase Internship" Weekly Diary (1)