Unity3D——相機跟隨物體移動

public Transform target;
public float moveSmooth=5f;
Vector3 offset;
void Start () {
offset = transform.position - target.position;//獲取相對位置
}


void Update () {
Vector3 targetPostion= offset + target.position;
transform.position = Vector3.Lerp(transform.position, targetPostion, moveSmooth*Time.deltaTime);
// transform.position = targetPostion;
}orm

相關文章
相關標籤/搜索