1、安装
window->package manager
2、创建Cinemachine
右键->Cinemachine->2D Carmera
3、创建空对象和多边形控制器如图
记得勾选 is Trigger
空对象位置记得要和小鸟保持一致,不然等下写完脚本后,镜头一开始会移动一下
4、将多边形触发器拖拽到2d Camera中,如图
5、给多边形触发器写个脚本随着小鸟镜头移动,不然小鸟会被挤出镜头
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class NewBehaviourScript : MonoBehaviour
{private GameObject player;// Start is called before the first frame updatevoid Start(){player = GameObject.Find("player");}// Update is called once per framevoid Update(){//水平跟随玩家transform.position = new Vector3(player.transform.position.x, transform.position.y, transform.position.z);}
}
把脚本拖拽给多边形触发器