Unity3D Slerp旋转速度

 手机用户2502885835 发布于 2023-02-13 13:58

我正在使用Unity3D.我想旋转一个物体面向鼠标指针的方向,但允许最大旋转速度,如"每秒最大100度".

文档中有一个例子,但它没有做我想要的.
我认为Time.time应该是Time.deltaTime,我无法真正理解最后一个参数的作用.它应该是与起始向量相加的数字吗?
http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.Slerp.html

另外,我无法真正理解最后一个参数的作用.这是轮换的时候吗?

我正在使用的代码

Plane plane = new Plane(Vector3.up, 0);
float dist;
void Update () {
    //cast ray from camera to plane (plane is at ground level, but infinite in space)
    Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
    if (plane.Raycast(ray, out dist)) {
        Vector3 point = ray.GetPoint(dist);

        //find the vector pointing from our position to the target
        Vector3 direction = (point - transform.position).normalized;

        //create the rotation we need to be in to look at the target
        Quaternion lookRotation = Quaternion.LookRotation(direction);

        //rotate towards a direction, but not immediately (rotate a little every frame)
        transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * rotationSpeed);
    }
}

我认为弱点位于Slerp的第三个参数中,但我无法弄清楚要放在那里的内容.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有