0

I'm implementing a camera for a game and I'm using the LERP formula for smooth chasing. However, if the target moves fast enough, the camera can never reach it unless the t ((1 - t) * v0 + t * v1) value is high enough, but that is exactly the problem: some targets might still move faster than the current t value.

This might lead to 2 problems:

  1. The camera will never reach the object if it's super fast
  2. The camera will very slowly reach the object, depending on it's current speed

How do I scale up my t when the delta distance (abs(v1 - v0)) gets lower, so that the camera will starts at a slow chasing rate and increases as it gets closer (therefore no targets could run away)?

Yves Calaci
  • 1,019
  • 1
  • 11
  • 37
  • I kinda managed to solve this by increasing `t` over time, as it will eventually reach `1` (guaranting to reach the target). If there's a better way to doing this, I'm all ears :) – Yves Calaci Jul 18 '20 at 08:37
  • Your question is unclear. What are `v0` and `v1`? Can you give us a complete example? – Beta Jul 18 '20 at 17:01
  • @Beta v0 and v1 are points you want to interpolate on (start and end). You can check the formula's link above – Yves Calaci Jul 18 '20 at 18:34
  • Yes, but you have not explained how `v0`, `v1` and `t` correspond to the motions of the target and the camera. You have a target that starts at location **T0** with constant velocity **z**, and a camera that starts at location **C0**. *What do you want the camera to do?* Move at constant velocity to intercept the target? At a given time? Or at a given place? Or something else? – Beta Jul 18 '20 at 19:24
  • I'm not sure what you mean with "a given place", but anyways `v0` is the camera's position and `v1` is the target's. The `t` was a small factor that gave a nice smoothness, however if the target was moving, there were cases that `t` was low enough to reach `v1`. I solved it by using `t = min(t + SOME_CONSTANT_FACTOR, 1)`, that way `t` scales up to 1, which then the LERP would return the `v1`'s value at some point, reaching the moving object. However, I was looking for some formulas that wouldn't require to sum up `t` every camera tick (game loop). – Yves Calaci Jul 18 '20 at 20:10

0 Answers0