在下面的lerping功能中,它会减慢跟随移动物体的摄像机的速度,并且当移动物体减速或停止摄像机赶上它时。我需要相反的。我需要相机移动到移动物体之前,并在物体减速/停止时减速回到物体。我似乎无法使其发挥作用。有任何想法吗?
//this is the opposite of what I want.
float lerp = 0.1f;
Vector3 position = this.getCamera().position;
position.x += (Obj.x - position.x) * lerp;
position.y += (Obj.y - position.y) * lerp;
答案 0 :(得分:0)
只需增加到110%
,而不是减少到10%
float lerp = 1.1f;
position.x += (Obj.x + position.x) * lerp;
position.y += (Obj.y + position.y) * lerp;
示例:
public static void main(final String[] args)
{
double position = 0;
for (int i = 0; i < 100; i++)
{
position = (position + 10) * 1.1;
System.out.println("position = " + position);
}
}