I've got a camera which is moving to an end position. For the entire duration of the movement, I want to frame an object so the motion looks appealing to the player. The framing of the object does not necessarily stay the same throughout the entire motion ( I want to be able to lerp the viewport position of the object during the lerp )
For each update in my lerp:
[1] - I tween between the start and end position of the camera.
[2] - I tween a viewport position that I want to use between start and end viewport position
[3] - I need to calculate the new rotation required to keep the object in my new viewport position calculated in [2]
[4] - I update the rotation and continue the lerp
However, I'm a bit stumped with the calculation in 3 :( I've tried a few variations to try and calculate this, but I can't seem to find a good solution. Does anyone know how to calculate this? Am I approaching this from the correct angle?
The Quaternion.LookRotation() method should be enought:
public GameObject TargetObject;
public GameObject CameraObject;
void Update () {
CameraObject.transform.rotation = Quaternion.LookRotation(TargetObject.transform.position- CameraObject.transform.position );
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.