c# - Quaternion.Lerp 甚至没有移动

标签 c# unity3d

我想 lerp 旋转到 new Quaternion(0,0,0,0);但它似乎根本没有动画到所需的旋转......它只是停在它所在的地方......

我试的是下面那三个

RectTransform rectTransformComponent = this.transform.GetComponent<RectTransform>(); rectTransformComponent.localRotation = Quaternion.Lerp(rectTransformComponent.localRotation, new Quaternion(0,0,0,0), 0.1f);

this.transform.localRotation = Quaternion.Lerp(this.transform.localRotation, new Quaternion(0,0,0,0), 0.1f);

this.transform.rotation = Quaternion.Lerp(this.transform.rotation, new Quaternion(0, 0, 0, 0), 0.1f);

我正在为此对象使用 RectTransform。它工作时没有麻痹。它在 Update() 中,所以它会在每一帧循环。我试图提高 lerp 的速度,但没有运气......

有人知道发生了什么事吗??

this.transform.localRotation = new Quaternion(0,0,0,0) //This works

最佳答案

全零四元数 (new Quaternion(0,0,0,0)) 是无效旋转。 Quaternion.Lerp 不知道如何对无效旋转进行插值。

要旋转到 x=0,y=0,z=0 的欧拉旋转,那么您应该改用 Quaternion.identity(相当于 new Quaternion(0, 0,0,1))。

关于c# - Quaternion.Lerp 甚至没有移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46410965/

相关文章:

c# - 在映射文件的 NHibernate ID 生成器部分中,分配和选择的含义是什么?

c# - 单元测试项目c#上的相对路径

c# - EventSource - 无法获取要应用的方法签名更改

c# - 如何从用 C++ 编写的外部 dll 中获取 const char * 到 C#

c# - 枚举与索引与迭​​代

c# - 在配置准备好之前配置 Serilog?

c# - 无法从客户端执行服务器命令

algorithm - 将 3D 平面上的点转换为 2D 点的程序

android - Unity ARFoundation Gradle构建失败-拒绝last-build.bin访问

Unity 3D/2D 中的 C# : Am I required to use Classes for every script?