当前位置:网站首页>unity裏現實攝像頭運鏡並LookAt到物體前方 基於Dotween

unity裏現實攝像頭運鏡並LookAt到物體前方 基於Dotween

2022-06-21 07:34:00 孤烟冷~

unity裏現實攝像頭運鏡並LookAt到物體前方 基於Dotween

1.基於Dotween 為了避免使用Update或循環帶來的每幀多餘消耗
2.這裏控制的是主相機到一個物體的運鏡

 		// plane.transform.GetChild(0)需要到達的物體
        //得到倆個點的距離(可以根據倆個物體遠近距離來計算運鏡時間長短)
        float lenth = (Camera.main.transform.parent.position - plane.transform.GetChild(0).position).magnitude;
        //移動到相應比特置
        Camera.main.transform.parent.DOMove(plane.transform.GetChild(0).position + new Vector3(0, 2, 1), Mathf.Clamp(lenth / 1000f, 0.3f, 1.5f));
        //LookAt看向相應比特置
        Camera.main.transform.parent.DOLookAt(plane.transform.GetChild(0).forward, Mathf.Clamp(lenth / 1000f, 0.3f, 1.5f));
原网站

版权声明
本文为[孤烟冷~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206210733354091.html