Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Time.deltaTime使用正反方向旋转对象_C#_Unity3d_Math - Fatal编程技术网

C# 使用Time.deltaTime使用正反方向旋转对象

C# 使用Time.deltaTime使用正反方向旋转对象,c#,unity3d,math,C#,Unity3d,Math,我想知道当一个物体只能在一个圆上移动时,如何使用time.deltaTime移动它 在本例中,我处理的是一个围绕播放器旋转的相机 _GoalX += Input.GetAxis("Mouse X"); float y = _PlayerHeight; float x = Mathf.Cos(_GoalX); float z = Mathf.Sin(_GoalX); transform.localPosition = new Vector3(x, y, z

我想知道当一个物体只能在一个圆上移动时,如何使用time.deltaTime移动它

在本例中,我处理的是一个围绕播放器旋转的相机

    _GoalX += Input.GetAxis("Mouse X");

    float y = _PlayerHeight;
    float x = Mathf.Cos(_GoalX);
    float z = Mathf.Sin(_GoalX);
    transform.localPosition = new Vector3(x, y, z);
摄像机不应立即放置在终点位置,而应随着时间的推移,在球员周围的圆圈上移动

    _GoalX += Input.GetAxis("Mouse X");

    float y = _PlayerHeight;
    float x = Mathf.Cos(_GoalX);
    float z = Mathf.Sin(_GoalX);
    transform.localPosition = new Vector3(x, y, z);

我不能使用Vector3.Lerp(startvector,targetvector),因为这样相机可能会进入播放器。

在更新中,您可以这样做:

    _GoalX += Input.GetAxis("Mouse X");

    float y = _PlayerHeight;
    float x = Mathf.Cos(_GoalX);
    float z = Mathf.Sin(_GoalX);
    transform.localPosition = new Vector3(x, y, z);
void update(){
angle += RotateSpeed * Time.deltaTime;
Vector3 offset = new Vector3(Mathf.Sin(_angle)* xRadius, _PlayerHeight, Mathf.Cos(_angle)* zRadius);
transform.position = _centre + offset;
}

您必须执行类似于
position=(player.x+距离*cos(phi),player.y+摄像机高度高于player,player.z+距离*sin(phi))
(伪代码)