游戏场景——玩家—小地图
先在场景中再创建一个摄像机,然后将其挂载的AudioListener组件移除(一山不能容二虎),然后再在project中创建一个RenderTexure
然后再把这个RenderTexure拖拽到我们之前创建的texMap上即可
然后将摄像机改成俯视,将摄像机设置成为坦克的子对象即可。但是如果这样做的话,摄像机也会跟着坦克旋转——而我们又不希望小地图的摄像机跟着坦克旋转,所以就不能通过父对象的方法来实现跟随,而是要写一个脚本来控制该摄像机的移动。
lateUpdate是为了防止抖动
CameraMove的代码为
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Camera : MonoBehaviour
{
//看向的对象
public Transform target;
//设置坐标
private Vector3 pos;
public int H = 20;
void LateUpdate()
{
if (target == null)
return;
pos.x = target.position.x;
pos.z = target.position.z;
pos.y = H;
this.transform.position = pos;
}
}