I’ve digicam a that’s actively following an object (a airplane) from behind. This object can speed up or decelerate.
I want to have a digicam offset after I transfer the airplane, so it does not look so static.
I’ve performed this with the next code:
float cameraOffset = 0.05 * elapsed_time * 100; Vector3 previousEye = camera->eye; Vector3 newEye = ship->mannequin * Vector3(0, 10, -5); Vector3 eye = previousEye * (1 - cameraOffset) + newEye * cameraOffset; Vector3 previousCenter = camera->middle; Vector3 newCenter = ship->mannequin * Vector3(0, 0, 10); Vector3 middle = previousCenter * (1 - cameraOffset) + newCenter * cameraOffset; Vector3 up = ship->mannequin.rotateVector(Vector3(0, 1, 0)); camera->lookAt(eye, middle, up); previousModel = ship->mannequin;
It really works high quality, besides that after I improve the thing’s pace, the digicam barely follows it. That is in fact logical; my code is meant to make it tough for the digicam to observe the airplane.
Nevertheless, I want to have a lateral digicam offset and likewise to maintain following the airplane from a comparatively brief distance.
Any trace on learn how to obtain that is appreciated.