Unity3D follow.
来源:互联网 发布:织梦小说源码 编辑:程序博客网 时间:2024/06/05 20:21
using UnityEngine;using System.Collections;public class CameraFollow : MonoBehaviour { [SerializeField] private Transform target; public float smooth = 0.5f; public bool isSmooth = true; public float height = 6.0f; public float distance = 5.0f; public float distanceRotationX = 30.0f; private Vector3 nextCameraPosition; private Quaternion nextCameraRotation; void Update () { #region CameraPosition Move. Vector3 currentV = transform.position; float resultX = target.position.x; float resultY = target.position.y + height; float resultZ = target.position.z - distance; nextCameraPosition = Vector3.Lerp (currentV, new Vector3 (resultX, resultY, resultZ), smooth * Time.deltaTime); #endregion #region CameraRotation Move. float currentRX = transform.eulerAngles.x; float currentRY = transform.eulerAngles.y; float currentRZ = transform.eulerAngles.z; float resultRotationX = target.eulerAngles.x + distanceRotationX; float resultRotationY = target.eulerAngles.y; float resultRotationZ = target.eulerAngles.z; resultRotationX = Mathf.LerpAngle (currentRX, resultRotationX, smooth * Time.deltaTime); resultRotationY = Mathf.LerpAngle (currentRY, resultRotationY, smooth * Time.deltaTime); resultRotationZ = Mathf.LerpAngle (currentRZ, resultRotationZ, smooth * Time.deltaTime); nextCameraRotation = Quaternion.Euler (resultRotationX, resultRotationY, resultRotationZ); #endregion transform.position = nextCameraPosition; transform.rotation = nextCameraRotation; }}
0 0
- Unity3D follow.
- follow me
- Smooth Follow
- Follow Your Dreams
- Follow Your Dreams
- Follow Your Dreams
- 求解FIRST & FOLLOW集
- Follow me on Twitter !
- Follow My Dream
- follow your heart
- follow my heart
- 计算Follow集合
- Follow your tracks
- follow your heart
- Commit failed (details follow):
- notify-send focus follow
- Follow and callFunc.
- Follow Me: ArcPy(1)
- 15章 上机2
- 那些必须知道的ADB命令
- 蓝鸥零基础学习HTML5第五讲 CSS的基础样式
- Remix OS 安装及初次使用心得
- 学习tomcat之通过shell批量管理多个tomcat
- Unity3D follow.
- iOS APP图标一键生成
- lua定时器与定时任务的接口设计
- 使用随机算法产生一个数,要求把1-1000W之间这些数全部生成。
- 15章 上机1
- 123. Best Time to Buy and Sell Stock III(dp)
- sha1签名
- 15章 上机4商品批发显示总金额
- [深度学习论文笔记][Weight Initialization] Delving deep into rectifiers: Surpassing human-level performance