我正在试着给什么时候停止相机跟踪我的角色设置一个上限。所需的停止值为0.3和-0.3。我曾尝试使用if语句告诉它在达到这些值时停止lerping,但是一旦它达到其中一个值,lerping就会永远停止。
this.transform.position = Vector3.Lerp(this.transform.position, new Vector3(xPositionOfAllPlayers / player.Length, yPositionOfAllPlayers / player.Length, this.transform.position.z), 0.1f);发布于 2014-02-20 04:00:29
首先,你是using Lerp() incorrectly。
其次,要钳制向量值,可以使用Mathf.Clamp()
Vector3 cameraPosition = Vector3.Lerp(/*Put arguments here, see link above*/);
this.position = new Vector3(Mathf.Clamp(cameraPosition.x, -0.3, 0.3),
Mathf.Clamp(cameraPosition.y, -0.3, 0.3),
cameraPosition.z);https://stackoverflow.com/questions/21816100
复制相似问题