首页 > 其他 > 详细

噩梦5 camera跟随

时间:2015-07-28 18:48:29      阅读:244      评论:0      收藏:0      [点我收藏+]

技术分享

namespace CompleteProject
{
    public class CameraFollow : MonoBehaviour
    {
        public Transform target;            // The position that that camera will be following.
        public float smoothing = 5f;        // The speed with which the camera will be following.




        Vector3 offset;                     // The initial offset from the target.




        void Start ()
        {
            // Calculate the initial offset.
            offset = transform.position - target.position;
        }




        void FixedUpdate ()
        {
            // Create a postion the camera is aiming for based on the offset from the target.
            Vector3 targetCamPos = target.position + offset;


            // Smoothly interpolate between the camera‘s current position and it‘s target position.
            transform.position = Vector3.Lerp (transform.position, targetCamPos, smoothing * Time.deltaTime);
        }
    }
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

噩梦5 camera跟随

原文:http://blog.csdn.net/haifeng619/article/details/47106597

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!