当前位置:网站首页>Unity learning notes – infinite map
Unity learning notes – infinite map
2022-07-26 14:32:00 【renwen1579】
Unity Learning notes -- Infinite map ( Map mosaic )_ Qiu Ming's blog -CSDN Blog _unity Infinite map
Unity Learning notes – Infinite map
In many simple stand-alone Parkour or racing games , You don't need to build a big map , You can use small map splicing to realize the function of infinite map .
The specific idea is : The player is somewhere on the map , When we are about to go out of the border , The map creates another one in front of the character for splicing , It seems that the map can never be finished .
unity There are two inside Plane With a cube Make an introduction :

default Plane The size is 10x10m, Two Plane Under one goal ;
use Cube Replace the player , Along the Z Drag in the direction cube when ,plane Will follow the alternate generation ;
Don't talk much , Code up :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class AddPlane : MonoBehaviour
{const float width = 10f;// Here is the width of the plane
public Transform player;
Vector3 initPos;
void Start()
{
initPos = transform.position;
}void Update()
{
float totalWidth = width*2f;// * backGroundNum;
float distZ = player.position.z - initPos.z;// Calculate the distance between the player and the insertion point in real time
int n = Mathf.RoundToInt(distZ / totalWidth);// Round it upvar pos = initPos;
pos.z += n * totalWidth;
transform.position = pos;
}
}
边栏推荐
- Job 7.25 sorting and searching
- Transc knowledge representation model
- [untitled]
- Keyboard shortcut to operate the computer (I won't encounter it myself)
- 敏捷开发与DevOps的对比
- 基于专利多属性融合的技术主题划分方法研究
- 1-to-1 live broadcast source code - 1-to-1 voice chat source code
- 【论文阅读】GRAW+:A Two-View Graph Propagation Method With Word Coupling for Readability Assessment
- 多线程——线程池
- Install dexdump on win10 and remove the shell
猜你喜欢

手持振弦采集仪VH03各种接口使用说明

Fill in the questionnaire and receive the prize | we sincerely invite you to fill in the Google play academy activity survey questionnaire

10 schemes to ensure interface data security

VP video structured framework

Multi task text classification model based on tag embedded attention mechanism

嵌入式开发:调试嵌入式软件的技巧

@A thousand lines of work, ride the cloud together!

~6. CCF 2021-09-1 array derivation

基于多特征的技术融合关系预测及其价值评估

Install dexdump on win10 and remove the shell
随机推荐
When AI encounters life and health, Huawei cloud builds three bridges for them
[GYCTF2020]FlaskApp
[ostep] 04 virtualized CPU - process scheduling strategy
低功耗多通道WFAS1431无线数据采集采发仪使用流程说明
【深度学习】全连接网络
GOM登录器配置免费版生成图文教程
1-to-1 live broadcast source code - 1-to-1 voice chat source code
win10安装Dexdump并脱壳
First knowledge of opencv4.x --- image perspective transformation
Annotation and reflection
基于双层主题模型的技术演化分析框架及其应用
UDP多线程在线聊天
请问下大家,flink sql有没有办法不输出update_before?
【数学建模】常用基本模型总结
How to evaluate the test quality?
智能家居行业发展,密切关注边缘计算和小程序容器技术
Install dexdump on win10 and remove the shell
[ostep] 03 virtualized CPU - restricted direct execution mechanism
C language_ Combination of structure and array
1对1直播源码——1对1语音聊天源码