当前位置:网站首页>Project training - Design and development of 2D multiplayer scuffle game based on unity (small map modified and improved)
Project training - Design and development of 2D multiplayer scuffle game based on unity (small map modified and improved)
2022-04-22 19:05:00 【Xyxxi】
Catalog
One 、 Preface
Because of the game design , The scene is large , And the final player after playing the relevant game , Still need to go back to the central point for other activities , Simply use a small map that shows only part of the scene , It may make it difficult for players to find the center point in the scene , Affect game efficiency .
Two 、 Making a little map
1. Map making
2. Small map beautification
Add related masks and buttons , At the same time, add a image, Drag in the picture of the small arrow , Represents the character indication on the small map
3、 ... and 、 The small map shows the movement and direction of the protagonist
Add a script
void Update () {
minicamera.transform.position = new Vector3(player.position.x, minicamera.transform.position.y, player.position.z);
miniplayerIcon.eulerAngles = new Vector3(0, 0, -player.eulerAngles.y);
}
Put the camera of the small map 、 figure 、 Arrow assignment

The final result is as follows , When the character turns , The arrow will also rotate

Four 、 Zoom in on the small map 、 narrow
Prior knowledge :
The camera
On the small map ±image add to button Components

Add a function to change the size of the map
public void ChangeMapSize(float value)
{
mapSize += value;
mapSize = Mathf.Clamp(mapSize, minSize, maxSize);
minicamera.orthographicSize = mapSize;
}
}
Increase the camera maximum and minimum limits
public float minSize;// Mini Map orthographicSize minimum value
public float maxSize; // Mini Map orthographicSize Maximum

The value passed in on the button ,-+ The buttons of the symbol are positive and negative numbers respectively . Value customization

final result :

Click on + Button

Click on - Button

The two figures show that the visible map range has changed
5、 ... and 、 Size map
Copy the mini map you have made

Consider the size of the map :
- Large maps don't need zoom in and out , Delete ± Button
- The size map shows different sizes
Switch between large and small maps
// Open the big map
public void OpenMaxmap()
{
maxmap.gameObject.SetActive(true);
minimap.gameObject.SetActive(false);
minicamera.orthographicSize = Maxmapsize;
}
// Open the mini map
public void OpenMinimap()
{
maxmap.gameObject.SetActive(false);
minimap.gameObject.SetActive(true);
minicamera.orthographicSize = mapSize;
}
meanwhile , More than the last code public float Maxmapsize;// Of the big map orthographicSize size , This variable is used to expand the range of the camera , It's assigned to the big map , The scope of a large map is larger than that of a small map . The assignment is as follows :

And expanding the big map 、 Add relevant methods on the mini map button , You can click the button to switch the size of the map .

give the result as follows :


6、 ... and 、 The big map shows the protagonist's movement and direction
Mobile and other codes are the same as small maps , Added the following
maxplayerIcon.eulerAngles = new Vector3(0, 0, -player.eulerAngles.y);
Make the person icon in the map according to 3D The person of the object rotates and rotates
At the same time, in order to switch the map, it also adds isMaxmap The variable of , The purpose is to detect whether to open the big map .
// Open the big map
public void OpenMaxmap()
{
maxmap.gameObject.SetActive(true);
minimap.gameObject.SetActive(false);
minicamera.orthographicSize = Maxmapsize;
isMaxmap = true;
}
// Open the mini map
public void OpenMinimap()
{
maxmap.gameObject.SetActive(false);
minimap.gameObject.SetActive(true);
minicamera.orthographicSize = mapSize;
isMaxmap = false;
}
版权声明
本文为[Xyxxi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221902144157.html
边栏推荐
- [spark] (task6) spark RDD completes the statistical logic
- Better than SQL, another domestic database language was born
- System Analyst - paper writing framework construction
- Secretary of the national security and Defense Commission of Ukraine: it is impossible to restore Ukraine's nuclear status at present
- Line by line interpretation of redet code
- 2019-12-07 wav audio cutting and merging
- [Luogu] p2372 yyy2015c01 challenge perimeter (BFS)
- 防火门能申请BS 476-21 耐火测试吗?
- Will map () in JS change the original array
- What happens when you run the NPM install command?
猜你喜欢

网络安全——Burp Suite抓包工具的使用

Nat. Commun. |用于学习生成模型的神经编码框架

【TCP】TCP 三次握手与四次挥手

Type of Flink window

可以惊艳你的登录网页

Issues related to redis in Linux system

Introduction to ribbon of microservice load balancer

mysql查询带序列号

蓝牙盾/颈椎按摩仪/迷你充电宝/探头温度记等,段码LCD液晶显示驱动IC-VK1088B QFN32 4*4超小体积,22seg*4com且可通过指令进入省电模式

leetcode:642. Design search automatic completion system
随机推荐
Mmdeploy quick start
借《Mastering ABP Framework》好好学学这个框架
漂亮舒服的KN95口罩,防护能力也很强
2020-01-14 DAPP development environment construction
Cvpr2022 𞓜 collaborative dual stream visual language pre training model for cross modal retrieval
[network security] duomics variable coverage vulnerability from white box test to actual combat
What does %[^\n] mean in C?
VS 2022 安装vld内存泄漏检测工具
Better than SQL, another domestic database language was born
1372: Xiao Ming's bill
Nat. Commun. | Neural coding framework for learning generation model
Welcome page display
【洛谷】P2372 yyy2015c01挑战算周长(BFS)
错误 C4996 ‘fopen‘: This function or variable may be unsafe. Consider using fopen_s instead. To disabl
What does naas, a charging service provider, rely on to rise without building piles?
【2022初春】【LeetCode】695. 岛屿的最大面积
Can amaze your login page
The research group of Shenzhen University issued the evaluation report on sustainable development of Shenzhen (2016-2021)
Picture to Base64
transfer方法详解