lerping旋转看起来不对劲

时间:2018-02-19 08:02:12

标签: c# unity3d lerp

我有一个功能可以将相机前面的物体拉到"拾取/保持"说对象。但是,在握住对象时,如果我以某种方式将其击中另一个对象,则所保持的对象将以意外的方式旋转。我没有在脚本中的任何位置更改对象的旋转。发生了什么,我怎么能解决这个问题,以便它正确旋转? This is what it looks like

void Grab()
{
    if (musketState == MusketState.Grab) 
    {
        objectToGrab = hit.transform.gameObject;
        Rigidbody objectRigidbody = objectToGrab.GetComponent<Rigidbody> ();
        Vector3 desiredPosition = mainCamera.transform.position + mainCamera.transform.forward * grabDistance;
        Vector3 smoothedPosition = Vector3.Lerp (objectToGrab.transform.position, desiredPosition, smoothSpeed * Time.deltaTime);

        isGrabbingObject = true;
        objectRigidbody.useGravity = false;
        objectRigidbody.transform.position = smoothedPosition;
    }
}

0 个答案:

没有答案