首页 > 解决方案 > unity 自行车踏板同步动画脚本

问题描述

我正在尝试在 Unity 中为我的自行车模型制作动画,因为我将动画装备与骑自行车的模型一起使用,并且我能够使用以下代码对其进行动画处理。

    private void RotateRightFoot(
    float in_deltatime
)
{
    Vector3 targetPos = 
                _rightPositions[_rightIndex].localPosition;
    Vector3 curPos = 
                _RightFootTarget.transform.localPosition;
    targetPos.z = 
                curPos.z;
    float step =
                _speed * in_deltatime;
    Vector3 newRot = 
                Vector3.MoveTowards(curPos,targetPos,step);
    
    _RightFootTarget.localPosition = 
                                newRot;

    if( curPos == targetPos )
    {
        _rightIndex++;

        if( _rightIndex >= _positions.Length )
        {
            _rightIndex = 0;
        }

        _startRightPos = 
                    targetPos;
    }
}

使用上面的代码,我在自行车踏板上移动右脚,但现在我想将踏板与骑自行车的人的脚部运动同步,因为我不擅长数学,所以我不知道如何完成它。

我在踏板上有一个 pvot,所以我要做的就是旋转它,但我不知道要旋转多少..

标签: c#unity3d

解决方案


推荐阅读