Unity3D Quaternion的一些记录
2014-03-19 10:07
316 查看
1、一个物体面向另一个物体
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
myTransform面向target。
或者:
transform.LookAt(target);
都可以
2、
function ToAngleAxis (out angle : float, out axis :
Vector3) : void
一个物体,沿着某一个轴axis的旋转角度
eg:
Quaternion pRotation = player.transform.localRotation;
float a = 0.0f;
Vector3 b = Vector3.up;
pRotation.ToAngleAxis(out a, out b);
float angle;
if (pRotation.y >= 0)
{
angle = a;
}
else
{
angle = 360 - a;
}
Debug.Log("angle = " + angle);
transform.localEulerAngles= new Vector3(0, 0, angle);
3、static function Angle (a : Quaternion, b : Quaternion) : float
两个 物体之间的角度
4、function SetFromToRotation (fromDirection :
Vector3, toDirection : Vector3) : void
从from到to旋转
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
myTransform面向target。
或者:
transform.LookAt(target);
都可以
2、
function ToAngleAxis (out angle : float, out axis :
Vector3) : void
一个物体,沿着某一个轴axis的旋转角度
eg:
Quaternion pRotation = player.transform.localRotation;
float a = 0.0f;
Vector3 b = Vector3.up;
pRotation.ToAngleAxis(out a, out b);
float angle;
if (pRotation.y >= 0)
{
angle = a;
}
else
{
angle = 360 - a;
}
Debug.Log("angle = " + angle);
transform.localEulerAngles= new Vector3(0, 0, angle);
3、static function Angle (a : Quaternion, b : Quaternion) : float
两个 物体之间的角度
4、function SetFromToRotation (fromDirection :
Vector3, toDirection : Vector3) : void
从from到to旋转
相关文章推荐
- 中文分词的一些研究记录
- OpenCV一些知识记录
- android camera开发的一些问题记录(上)
- [乐意黎转载]关于JS 命名和数组的一些记录
- 记录MySQL的一些基础操作
- .net 一些日志记录第三方工具
- wcf一些记录
- 记录centos7.x下network and 一些服务启动
- 记录一下UGUI的Rectransform的一些属性
- 这里记录着一些很有用的博客
- 记录一些快捷键
- 记录android studio学习中脱的一些坑
- Maven 一些记录
- 记录一些容易忘记的属性 -- UIScrollView
- 工作中的一些小记录(命令用法、函数等)
- 数据库使用中一些问题解决记录
- 有关GCC的一些记录笔记
- 记录一些 Latex 的技巧
- js类库 一些常用方法记录
- EAS 一些基础数据的查询记录脚本(sql)