The idea of a camera that can freely observe irregular high-speed moving objects in unity

Source: Internet
Author: User
The idea of a camera that can freely observe irregular high-speed moving objects in unity

In unity, to allow the camera to freely observe a high-speed, irregular motion when a particular key is pressed, it is necessary to calculate the offset between the camera and the observed target at the time the key is pressed for subsequent operations. But there is a problem here, each time you press the button, the offset may have a frame of error, that is, when the button is pressed to observe the distance of the target forward one frame, but the camera is not followed, the calculated offset is too large, resulting in the camera away from the observation target is more and more distant.

The workaround is to add an empty object as the camera's parent node, take the camera as its child, and then let the parent node always follow the observation target (CamParent.transform.position = Target.transform.position), the parent node will go with the camera, so that it can only handle the camera's rotation and pull away from the parent node, without having to deal with camera tracking, in fact the camera is observing its parent node instead of observing the original object, but the final result is the same.

Note that the camera cannot be placed directly under the observation target unless the observed target is stationary or panning, otherwise the rotation of the viewing target causes the lens to rotate. In addition, if the picture needs to be scaled, when the camera is farther away from the viewing target, it can be achieved by adjusting the distance between the camera and the target, which can be achieved by adjusting the camera FOV when the camera is closer to the viewing target, thus avoiding the camera's penetration into the observation target.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.