C#/Unity Time.deltaTime 使 lerping Camera Follow 跳转

问题描述

我最近在 Unity 制作的 2D 游戏中发布了一个抖动相机跟随的问题,该问题已解决 here

但是过了一段时间我注意到,我仍然在跳跃。我现在知道,问题在于我的相机跟随的 lerp 方法。 Time.deltaTime 如我之前的问题所述而变化,因此使玩家每帧移动不同的距离。但是由于相机的反应有延迟,您可以在屏幕上看到跳跃(在设备上甚至比在 Unity 编辑器中更多)。

一个解决方案是检测那些 Time.DeltaTime 跳跃,在这些情况下让相机以某种方式模仿那个跳跃,我说得对吗?这里有什么解决方法?

这些是我的脚本:

public class Player: MonoBehaviour 
{ 
    float speed = 5f; 
    void Update() 
    { 
        transform.Translate(0,speed*Time.deltaTime,0); 
    } 
} 

public class CamFollow : MonoBehaviour 
{ 
    public Transform Player; 
    private Vector3 FollowVector; 
    float transition = 0.05f;
    void LateUpdate() 
    { 
        FollowVector = Player.position - new Vector3(0,-4.0f,10); 
        transform.position = Vector3.Lerp(transform.position,FollowVector,transition); 
    } 
} 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)