using UnityEngine;
using System.Collections;
public class BallCamera : MonoBehaviour
{
//跟随目标
public Transform target;
//跟随高度
public float relativeHeigth = 10.0f;
//跟随Z轴差值
public float zDistance = 5.0f;
//滑动差值
public float dampSpeed = 2;
void Update()
{
Vector3 newPos = target.position + new Vector3(0, 10, -zDistance);
//滑动跟随
transform.position = Vector3.Lerp(transform.position, newPos, Time.deltaTime * dampSpeed);
}
}
using System.Collections;
public class BallCamera : MonoBehaviour
{
//跟随目标
public Transform target;
//跟随高度
public float relativeHeigth = 10.0f;
//跟随Z轴差值
public float zDistance = 5.0f;
//滑动差值
public float dampSpeed = 2;
void Update()
{
Vector3 newPos = target.position + new Vector3(0, 10, -zDistance);
//滑动跟随
transform.position = Vector3.Lerp(transform.position, newPos, Time.deltaTime * dampSpeed);
}
}