-1
攝像機跟隨對象我做了一個播放器預製與標籤球員是在場景催生當遊戲starts.How我可以讓相機使用球員標籤跟隨玩家。如何使標籤
目前使用下面的腳本
public Transform target; // The position that that camera will be following.
public float smoothing = 5f; // The speed with which the camera will be following.
Vector3 offset; // The initial offset from the target.
void Start()
{
// Calculate the initial offset.
offset = transform.position - target.position;
}
void FixedUpdate()
{
// Create a postion the camera is aiming for based on the offset from the target.
Vector3 targetCamPos = target.position + offset;
// Smoothly interpolate between the camera's current position and it's target position.
transform.position = Vector3.Lerp (transform.position, targetCamPos, smoothing * Time.deltaTime);
}
給了一個錯誤**的NullReferenceException:對象沒有設置爲一個對象 CompleteProject.CameraFollow.FixedUpdate(的實例)(在資產/ _CompletedAssets /腳本/相機/ CameraFollow.cs:27)** –
其一個給錯誤你試過了哪一個?你有把標籤添加到目標對象嗎?你的物體什麼時候產卵?如果它開始使它在清醒時產卵 –
第一個給出錯誤 –