本文介绍了我怎么能复制这个lerping函数的反面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的lerping功能中,它会减慢跟随移动物体的摄像机的速度,并且当移动物体减速或停止摄像机赶上它时。我需要相反的。我需要相机移动到移动物体之前,并在物体减速/停止时减速回到物体。我似乎无法使其发挥作用。有任何想法吗?
In the lerping function below, it will slow down a camera which is following a moving object, and as the moving object slows down or stops the camera catches up to it. I need the opposite. I need the camera to move ahead of the moving object and slow down back to the object when the object slows/stops. I can't seem to make it work. Any ideas?
//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;
推荐答案
只需增加到 110%
而不是减少到 10%
just increase to 110%
instead of decreasing to 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);
}
}
这篇关于我怎么能复制这个lerping函数的反面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!