小地图制作

xiaoxiao2025-03-06  16

制作小地图一般有几个步骤:

首先需要建立一个相机:作用就是映射纹理图片到视图中

1:点击建立camera:下面是建立相机的属性

 

 

2:建立一个纹理;

create---->Render Texture

3:将新建的texture拖到相机里面,这样相机显示的内容就会映射到纹理里面

4:然后在画布里面建一个RawImage,将纹理放到里面

5:调整rawImage的位置,让他在视图的右上方显示:效果如下

 6:这里我们需要设置相机跟随猪脚移动,那么需要下面的代码来绑到相机上

  public class CameraFollow : MonoBehaviour     {         public Transform target;                     public float smoothing = 5f;     

        Vector3 offset;                     

        void Start ()         {                         offset = transform.position - target.position;         }

        void FixedUpdate ()         {                       Vector3 targetCamPos = target.position + offset;

                   transform.position = Vector3.Lerp (transform.position, targetCamPos, smoothing * Time.deltaTime);         }     }

这里相机跟随谁就把设置为target

将脚本绑定相机

当然这样还没有完成

7:给target添加上标识在地图中显示

在目标物体中添加子物体Quad,设置Quad的大小和位置

旋转90度,高度设置成大于10的数,太低了看不清,大小调整x,y,

这样小地图就基本完成

当然可能会遇到这个问题报错:

Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported in Unity 5.

If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component. Scene hierarchy path "Player/Quad", Mesh asset path "Library/unity default resources" Mesh name "Quad"

解决方式为如图:将quad中的组件convex组件打钩

 

转载请注明原文地址: https://www.6miu.com/read-5025651.html

最新回复(0)