Mathf.Lerp详解
< 返回列表时间: 2020-05-12来源:OSCHINA
常用于摄像机追随玩家 实现平滑跟踪
void Update () {
if (player != null) {
float x = Mathf.Lerp (this.transform.position.x , player.position.x , 0.2f);
float y = Mathf.Lerp (this.transform.position.y , player.position.y , 0.2f);
this.transform.position = new Vector3 (x , y , this.transform.position.z);
}
}
热门排行