如何模拟驾驶汽车方向盘的3D人形模型的动作?

时间:2018-11-10 02:25:07

标签: unity3d

我当前的代码:

using UnityEngine;
using System.Collections;

public class IKControl : MonoBehaviour {

    Animator animator; 
    public Transform RightFootIKPostion;
    public Transform LeftFootIKPostion;
    public Transform rightHandIKPostion;
    public Transform leftHandIKPosition;
    // Use this for initialization
    void Start () {
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void OnAnimatorIK(int layer){
        animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
        animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
        animator.SetIKPositionWeight(AvatarIKHint.LeftElbow, 1);
        animator.SetIKPositionWeight(AvatarIKHint.RightElbow, 1);
        animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
        animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
        animator.SetIKRotationWeight(AvatarIKHint.LeftElbow, 1);
        animator.SetIKRotationWeight(AvatarIKHint.RightElbow, 1);

        animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, 1);
        animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, 1);
        animator.SetIKPosition(AvatarIKGoal.RightFoot, RightFootIKPostion.position);
        animator.SetIKPosition(AvatarIKGoal.LeftFoot, LeftFootIKPostion.position);

        animator.SetIKPosition(AvatarIKGoal.RightHand, rightHandIKPostion.position);
        animator.SetIKRotation(AvatarIKGoal.RightHand, rightHandIKPostion.rotation);
        animator.SetIKPosition(AvatarIKGoal.LeftHand, leftHandIKPosition.position);
        animator.SetIKRotation(AvatarIKGoal.LeftHand, leftHandIKPosition.rotation);


    }
}

但是,旋转的只是模型的手,而不是肘部/前臂。

0 个答案:

没有答案