-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)** –
其一个给错误你试过了哪一个?你有把标签添加到目标对象吗?你的物体什么时候产卵?如果它开始使它在清醒时产卵 –
第一个给出错误 –