animation - Unity3d 中的动画旋转

标签 animation unity3d transitions

我正在 Unity3D 中开发 2D 游戏(使用 Orthello 2D)。

自从我从 Cocos2d 和 CoronaSDK 切换后,我想知道是否有一种方法可以在 Corona 中为 Sprite (或任何 Unity3D 对象)实现以下行为:

object = ...
transition.to ( object, { time = 1000, rotation = object.rotation + 100, onComplete = function () 
    // do something
end })

所以一个 Sprite 在 1 秒内旋转了 100 度。

在我附加到 Sprite 的脚本中,我可以在我的 Update () 函数中进行旋转,但它的方法有点不同......

最佳答案

您可以在更新函数中轻松完成。

float timer = 0f;

void Update()
{
    if(timer <= 1)
    {
// Time.deltaTime*100 will make sure we are moving at a constant speed of 100 per second
        transform.Rotate(0f,0f,Time.deltaTime*100);
// Increment the timer so we know when to stop
        timer += Time.deltaTime;
    }
}

如果您需要再旋转 100 度,您只需重置计时器即可。

可以看到不同版本的旋转功能here以及有关救生员 Time.deltaTime 值的更多信息 here

关于animation - Unity3d 中的动画旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19055112/

相关文章:

ios - 显示特定图像时禁用 iOS 中的按钮

scripting - 如何加载 Assets 包

android - Unity、Android 和 iOS 之间的共享首选项

css - div 中的图像 - 当鼠标悬停在潜水中的任何位置时

html - 如何使用 CSS 在图像之间交叉淡入淡出?

css - 悬停和鼠标移出的不同 CSS 过渡延迟?

android - 向 View 添加一些文本

jquery - 如何预先隐藏某些内容以准备在 jQuery 动画中公开它?

javascript - 使用淡入和淡出动画 block 中的文本变化

c# - 无法加载,因为已经加载了另一个具有相同文件的 AssetBundle