一、直接把主相机作为Player角色的子物体,并自行固定好相机的位置和角度
优点:使用方便
缺点:使用不灵活,相机转动死板,体验不好,相机瞬间移动位置
二、固定相机跟随,这种相机有一个参考对象,它会保持与该参考对象固定的位置,跟随改参考对象发生移动
优点:简单,方便
缺点:无法一直跟随角色身后,适合固定视角游戏
using UnityEngine;
using System.Collections;
public class CameraFlow : MonoBehaviour
{
public Transform target;
private Vector3 offset;
void Start()
{
//设置相对偏移
offset = target.position - this.transform.position;
}
void Update()
{
this.transform.position = target.position - offset;
}
}
三、固定相机跟随,带有角度旋转。这一种相机跟随是对第一种相机跟随的改进,在原有基础上面,添加了跟随角度的控制
using UnityEngine;
using System.Collections;
public class CameriaTrack : MonoBehaviour
{
private Vector3 offset = new Vector3(0,5,4);//相机相对于玩家的位置
private Transform target;