How to Do Camera Lerp easily


#1

I was googling/searching for a straightforward post about this and couldn’t find anything but concepts on how lerping works, so I just wanted to post my easy solution for it.

All you do is take your desired object location/point (PointX/Y) and subtract it by your camera location, multiply by 10% (you can use whatever number between 0-1 here to increase/decrease speed) and you are good to go.

It will basically recalculate distance constantly, making longer travel times fast and shorter travel times slow, giving it a nice smooth flow. If you wanted to make this more efficient, you could theoretically put in a framerate timer or something to slow down how many calculations it makes as every frame might be excessive. I’ll prolly do that later for my own project.

Nevertheless, this is one size fits all for a two point lerp check. Hope this can help someone.


#2

There is also a lerp function bundled in the mathematical expressions of GD.


#3

Ah interesting. I didn’t know that existed.

Though, as a non-programmer, I find the lerp function less intuitive than the math itself. I tried plugging in lerp(A (pointX), B (cameraX), .1) and that didn’t work.