当前位置:网站首页>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;
}
}
边栏推荐
- @A thousand lines of work, ride the cloud together!
- What is restful style and its four specific implementation forms
- 12437 words, take you to explore the principle of RPC communication
- GOM login configuration free version generate graphic tutorial
- Seata的部署与微服务集成
- Uni app from creation to operation to wechat developer tool
- OpenCV中图像算术操作与逻辑操作
- Comparison between agile development and Devops
- 【使用工具条绘图】
- unity透明通道的小技巧
猜你喜欢

A survey of machine learning based technology term recognition

Jzoffer51- reverse pairs in the array (merge sort solution)

Plato farm is expected to further expand its ecosystem through elephant swap

Focus on building four "highlands" and join hands with partners to build the national cloud!

智能家居行业发展,密切关注边缘计算和小程序容器技术

My meeting of OA project

如何评价测试质量?
![[GYCTF2020]FlaskApp](/img/ee/dcb42617af4a0e41657f6cf7095feb.png)
[GYCTF2020]FlaskApp

OA项目之会议排座和送审

Prediction and value evaluation of technology fusion relationship based on multiple features
随机推荐
MySQL-04 存储引擎和数据类型
Annotation and reflection
Detailed explanation of alter field of MySQL Foundation
C语言贪吃蛇-链表和指针练习
As the "first city" in Central China, Changsha's "talent attraction" has changed from competition to leadership
Basic syntax of MySQL DDL and DML and DQL
Uni app from creation to operation to wechat developer tool
Would you please refer to the document of Database specification?
maya将模型导入到unity
C language_ Structure pointer variable introduction
『云原生』KubeSphere可插拔组件之DevOps系统
Figure introduction to neural network core dataset
Mlx90640 infrared thermal imager temperature sensor module development notes (6)
什么是Restful风格以及它的四种具体实现形式
Would you please tell me if there is a way for Flink SQL not to output update_ before?
我的创作纪念日-从心出发
Meeting seating and submission for approval of OA project
多线程——线程池
[ostep] 03 virtualized CPU - restricted direct execution mechanism
Research on prediction of user churn in online health community based on user portrait