当玩家摔倒时,摄像机不会在z坐标系中移动



我的相机有问题。主要的问题是,如果玩家倒下,摄像机就不能跟随

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class camera : MonoBehaviour
{
public Transform target;
public Vector3 positionOffset;
public float smooth = 3.0f;
void Start()
{
positionOffset = gameObject.transform.position - target.position;
}
void LateUpdate()
{
transform.position = Vector3.Lerp(transform.position, new Vector3(target.position.x + 
positionOffset.x, positionOffset.y, target.position.z + positionOffset.z), Time.deltaTime 
* smooth);
}
}

以下是问题的链接:https://youtu.be/0RCEmrw3Xho

您错过了用目标位置更改Y位置。因此,正确的LateUpdate()应该是这样的:

void LateUpdate()
{
transform.position = Vector3.Lerp(transform.position, new Vector3(target.position.x + positionOffset.x, target.position.y + positionOffset.y, target.position.z + positionOffset.z), Time.deltaTime * smooth);
}

最新更新