【发布时间】:2016-03-29 08:56:43
【问题描述】:
我正在制作一个无尽的跳投,它变成了一个跌倒类型的游戏。相机在上升过程中非常流畅,但在下降过程中却非常生涩。
我不知道如何让它只跟随玩家的脚本而不是混蛋。
相机上升:
float newHeightOfCamera = Mathf.Lerp(currentCameraHeight, playerHeightY, Time.deltaTime * 10);
transform.position = new Vector3(transform.position.x, newHeightOfCamera, transform.position.z);
相机下降:
float newHeightOfCamera = Mathf.Lerp(currentCameraHeight, playerHeightY - fallCamera, Time.deltaTime);
transform.position = new Vector3(transform.position.x, newHeightOfCamera - cameraFallLocation, transform.position.z);
在向下的过程中,玩家会到达屏幕顶部并设置为固定速度。
pc.GetComponent<Rigidbody2D>().velocity = new Vector2(0, fallSpeed); //changes falling speed
【问题讨论】:
-
请注意,您如何在上行中使用
Time.deltaTime* 10 的时间范围。在下行中,您如何单独使用Time.deltaTime的时间范围。也可以尝试相乘 -
你能解释一下
fallCamera和cameraFallLocation是什么吗?这些值也会随时间变化吗? -
你的代码示例在哪里?同时更新还是在其他地方更新?