当前位置:网站首页>[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游戏制作.
边栏推荐
- Unable to log in to the Westward Journey
- Ask God to answer, how should this kind of sql be written?
- Centos7 install postgresql and enable remote access
- 优炫数据库导库导错了能恢复吗?
- [ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)
- The failure to create a role in Dahua Westward Journey has been solved
- 用位运算为你的程序加速
- ¶ Backtop back to the top is not effective
- 使用docker安装mysql
- 60 Feature Engineering Operations: Using Custom Aggregate Functions【Favorites】
猜你喜欢
Win Go development kit installation configuration, GoLand configuration
2022-08-01 mysql/stoonedb slow SQL-Q18 analysis
Golang分布式应用之定时任务
软件测试 接口自动化测试 pytest框架封装 requests库 封装统一请求和多个基础路径处理 接口关联封装 测试用例写在yaml文件中 数据热加载(动态参数) 断言
Entry name 'org/apache/commons/codec/language/bm/gen_approx_greeklatin.txt' collided
检查IP或端口是否被封
记一个gorm初始化的坑
Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas
【LeetCode每日一题】——103.二叉树的锯齿形层序遍历
FOFAHUB使用测试
随机推荐
LeetCode Brushing Diary: 74. Searching 2D Matrix
Safety (1)
Entry name 'org/apache/commons/codec/language/bm/gen_approx_greeklatin.txt' collided
ofstream,ifstream,fstream read and write files
AntPathMatcher uses
MySQL - CRUD operations
Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas
NIO‘s Sword(牛客多校赛)
Fly propeller power space future PIE - Engine Engine build earth science
AOF rewrite
Redis for distributed applications in Golang
to-be-read list
工程师如何对待开源
数据链路层的数据传输
2022-08-01 Install mysql monitoring tool phhMyAdmin
Golang分布式应用之定时任务
【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
Oracle19c安装图文教程
[Server data recovery] Data recovery case of server Raid5 array mdisk disk offline
[ORB_SLAM2] SetPose, UpdatePoseMatrices