赞
踩
使用函数Quaternion.LookRotation
1.得到当前位置和目标位置的方向
Vector3 dir = (new Vector3(desPos.position.x, 0, desPos.position.z) - new Vector3(transform.position.x, 0, transform.position.z)).normalized;
2.的到的方向通过LookRotation函数获得这个方向的四元数
Quaternion rot = Quaternion.LookRotation(dir);
3.使用插件DOTween中DORotate的旋转得到角度
transform.DORotate(new Vector3(rot.eulerAngles.x, rot.eulerAngles.y, rot.eulerAngles.z), 1.0f, RotateMode.Fast);
这个可以指定秒数旋转朝向。
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。