当前位置: 首页>>代码示例>>C#>>正文


C# Animator.GetBoneTransform方法代码示例

本文整理汇总了C#中UnityEngine.Animator.GetBoneTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Animator.GetBoneTransform方法的具体用法?C# Animator.GetBoneTransform怎么用?C# Animator.GetBoneTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Animator的用法示例。


在下文中一共展示了Animator.GetBoneTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    void Start()
    {
        // store the Animator component
        animator = GetComponent<Animator>();
        tpController = GetComponent<ThirdPersonController>();
        // find character chest and hips
        characterChest = animator.GetBoneTransform(HumanBodyBones.Chest);
        characterHips = animator.GetBoneTransform(HumanBodyBones.Hips);

        // set all RigidBodies to kinematic so that they can be controlled with Mecanim
        // and there will be no glitches when transitioning to a ragdoll
        setKinematic(true);
        setCollider(true);

        // find all the transforms in the character, assuming that this script is attached to the root
        Component[] components = GetComponentsInChildren(typeof(Transform));

        // for each of the transforms, create a BodyPart instance and store the transform 
        foreach (Component c in components)
        {
            BodyPart bodyPart = new BodyPart();
            bodyPart.transform = c as Transform;
            bodyParts.Add(bodyPart);
        }
    }
开发者ID:Meny22,项目名称:SmartClothingProject,代码行数:25,代码来源:Ragdoll.cs

示例2: Start

 void Start()
 {
     animator = GetComponent<Animator>();
     bone1 = animator.GetBoneTransform(HumanBodyBones.LeftFoot);
     bone2 = animator.GetBoneTransform(HumanBodyBones.RightFoot);
     shadow = transform.FindChild("Shadow");
     tr = transform;
 }
开发者ID:ConcoMB,项目名称:DungeonGilada,代码行数:8,代码来源:EnemyActor.cs

示例3: Start

    void Start()
    {
        animator = GetComponent<Animator>();

        leftFoot = animator.GetBoneTransform (HumanBodyBones.LeftFoot);
        rightFoot = animator.GetBoneTransform (HumanBodyBones.RightFoot);

        leftFootRot = leftFoot.rotation;
        rightFootRot = rightFoot.rotation;
    }
开发者ID:hannahjgb,项目名称:AdventureGameFiles,代码行数:10,代码来源:PlayerIK.cs

示例4: OnStateEnter

	 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
	override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		_components = animator.GetComponent<ComponentsList> ();
		_head = animator.GetBoneTransform (HumanBodyBones.Head);
		_leftHand = animator.GetBoneTransform (HumanBodyBones.LeftHand);
		_rightHand = animator.GetBoneTransform (HumanBodyBones.RightHand);
		_chest = animator.GetBoneTransform (HumanBodyBones.Chest);
		_spine = animator.GetBoneTransform (HumanBodyBones.Spine);
		_slot = _components.inventory._currentSlot;
		UpdateStatePower (animator,stateInfo,layerIndex);
	}
开发者ID:omgware,项目名称:UnityUnetMovement,代码行数:11,代码来源:MouseLook.cs

示例5: OnStateEnter

    private Quaternion m_spineDeltaRotation; // The delta rotation of the spine component.
    // private Quaternion m_targetRotation;  // The target rotation of the head?


    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state.
    override public void OnStateEnter (Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        m_components = animator.GetComponent<NetworkedRouterOfComponentsForObserver> (); // Query the ComponentList in the gameObject containing the Animator.
        m_head = animator.GetBoneTransform (HumanBodyBones.Head); // Populate the Head component.
        m_spine = animator.GetBoneTransform(HumanBodyBones.Spine); // Populate the Spine component.
        m_chest = animator.GetBoneTransform(HumanBodyBones.Chest); // Populate the Chest component.
        m_leftHand = animator.GetBoneTransform (HumanBodyBones.LeftHand); // Populate the Left Hand (off hand) component.
        m_rightHand = animator.GetBoneTransform (HumanBodyBones.RightHand); // Populate the Right Hand (gun hand) component.
        m_slot = m_components.inventory.m_currentSlot; // Populate from the current inventory slot of PlayerPrefab.
        UpdateStateProgress(animator, stateInfo, layerIndex);
    }
开发者ID:kamilion,项目名称:UNETMovement,代码行数:15,代码来源:NetworkedObserverSMMouseLook.cs

示例6: Start

 void Start()
 {
     animator = GetComponent<Animator>();
     bone1 = animator.GetBoneTransform(HumanBodyBones.LeftFoot);
     bone2 = animator.GetBoneTransform(HumanBodyBones.RightFoot);
     shadow = transform.FindChild("Shadow");
     List<Transform> list = new List<Transform>();
     foreach (Transform tf in GameObject.Find("Enemies").transform)
         list.Add(tf);
     enemies = list.ToArray();
     tr = transform;
 }
开发者ID:ConcoMB,项目名称:DungeonGilada,代码行数:12,代码来源:ChoiceActor.cs

示例7: Awake

    void Awake()
    {
        animator = transform.parent.GetComponent<Animator>();

        //*** Store the initial local bone positions before the animation puts the avatar out of T-pose
        {
            Transform trans = transform.parent;

            initialHeadPos = trans.InverseTransformPoint( animator.GetBoneTransform( HumanBodyBones.Head ).position );

            if ( useNeckBone )
                initialNeckPos = trans.InverseTransformPoint( animator.GetBoneTransform( HumanBodyBones.Neck ).position );

            initialLeftShoulderPos = trans.InverseTransformPoint( animator.GetBoneTransform( HumanBodyBones.LeftUpperArm ).position );
            initialRightShoulderPos = trans.InverseTransformPoint( animator.GetBoneTransform( HumanBodyBones.RightUpperArm ).position );

            initialLeftEllbowPos = trans.InverseTransformPoint( animator.GetBoneTransform( HumanBodyBones.LeftLowerArm ).position );
            initialRightEllbowPos = trans.InverseTransformPoint( animator.GetBoneTransform( HumanBodyBones.RightLowerArm ).position );

            initialLeftHandPos = trans.InverseTransformPoint( animator.GetBoneTransform( HumanBodyBones.LeftHand ).position );
            initialRightHandPos = trans.InverseTransformPoint( animator.GetBoneTransform( HumanBodyBones.RightHand ).position );

            Vector3 averageFootPosition = 0.5f * (animator.GetBoneTransform( HumanBodyBones.LeftFoot ).position +
                                                animator.GetBoneTransform( HumanBodyBones.RightFoot ).position );
            avatarScale = animator.GetBoneTransform( HumanBodyBones.Head ).position.y - averageFootPosition.y;
        }
    }
开发者ID:Tamulur,项目名称:AvatarExperiments,代码行数:27,代码来源:CameraAnchor.cs

示例8: Start

	void Start()
	{
		animator = GetComponentInChildren<Animator>();
		leftHand = animator.GetBoneTransform (HumanBodyBones.LeftHand);
		SetUpAnimator();
		
		  
	}
开发者ID:JonaSilva,项目名称:cozcyt,代码行数:8,代码来源:movimientoEnemigo.cs

示例9: Awake

void Awake()
{

animator = transform.parent.GetComponent<Animator>();


transform.parent = animator.GetBoneTransform(HumanBodyBones.Spine).transform;

}
开发者ID:PlayHopeless,项目名称:game,代码行数:9,代码来源:ShooterAIReferenceObject.cs

示例10: ArmBasics

    public ArmBasics(InstantVR ivr, BodySide bodySide_in, BodyMovementsBasics bodyMovements_in)
    {
        this.ivr = ivr;
        animator = ivr.GetComponentInChildren<Animator>();

        this.bodyMovements = bodyMovements_in;
        this.bodySide = bodySide_in;

        if (bodySide_in == BodySide.Left) {
            upperArm = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.LeftHand);

            if (bodyMovements.fromNormLeftHand == Quaternion.identity) {
                bodyMovements.fromNormLeftUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                bodyMovements.fromNormLeftForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                bodyMovements.fromNormLeftHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
            if (fromNormHand == Quaternion.identity) {
                fromNormUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                fromNormForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                fromNormHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
        } else {
            upperArm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.RightHand);

            if (bodyMovements.fromNormRightHand == Quaternion.identity) {
                bodyMovements.fromNormRightUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                bodyMovements.fromNormRightForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                bodyMovements.fromNormRightHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
            if (fromNormHand == Quaternion.identity) {
                fromNormUpperArm = Quaternion.Inverse(Quaternion.LookRotation(forearm.position - upperArm.position)) * upperArm.rotation;
                fromNormForearm = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * forearm.rotation;
                fromNormHand = Quaternion.Inverse(Quaternion.LookRotation(hand.position - forearm.position)) * hand.rotation;
            }
        }

        float upperArmLength = Vector3.Distance(upperArm.position, forearm.position);
        float forearmLength = Vector3.Distance(forearm.position, hand.position);
        length = upperArmLength + forearmLength;

        upperArmStartPosition = upperArm.position;
    }
开发者ID:paulchorba,项目名称:TrueVR,代码行数:46,代码来源:IVR_BodyMovementsFree.cs

示例11: CheckConsistency

        public void CheckConsistency( Animator animator, EyeAndHeadAnimator eyeAndHeadAnimator )
        {
            if ( eyeControl == EyeControl.MecanimEyeBones )
            {
                if ( null == animator )
                    throw new System.Exception("No Animator found.");
                if ( null == animator.GetBoneTransform(HumanBodyBones.LeftEye) || null == animator.GetBoneTransform(HumanBodyBones.LeftEye) )
                    throw new System.Exception("Mecanim humanoid eye bones not found.");

                if ( false == isEyeBoneDefaultSet )
                    SaveDefault( eyeAndHeadAnimator );
            }
            else if ( eyeControl == EyeControl.SelectedObjects )
            {
                if ( null == leftEye )
                    throw new System.Exception("The left eye object hasn't been assigned.");
                if ( null == rightEye )
                    throw new System.Exception("The right eye object hasn't been assigned.");

                if ( false == isEyeBallDefaultSet )
                    SaveDefault( eyeAndHeadAnimator );
            }

            if ( eyelidControl == EyelidControl.Bones )
            {
                if ( upperEyeLidLeft == null || upperEyeLidRight == null )
                    throw new System.Exception("The upper eyelid bones haven't been assigned.");
                if ( false == isEyelidBonesDefaultSet )
                    throw new System.Exception("The default eyelid position hasn't been saved.");
                if ( false == isEyelidBonesClosedSet )
                    throw new System.Exception("The eyes closed eyelid position hasn't been saved.");
                if ( false == isEyelidBonesLookUpSet )
                    throw new System.Exception("The eyes look up eyelid position hasn't been saved.");
                if ( false == isEyelidBonesLookDownSet )
                    throw new System.Exception("The eyes look down eyelid position hasn't been saved.");
             }
             else if ( eyelidControl == EyelidControl.Blendshapes )
             {
                if ( false == isEyelidBlendshapeDefaultSet )
                    throw new System.Exception("The default eyelid position hasn't been saved.");
                if ( false == isEyelidBlendshapeClosedSet )
                    throw new System.Exception("The eyes closed eyelid position hasn't been saved.");
                if ( false == isEyelidBlendshapeLookUpSet )
                    throw new System.Exception("The eyes look up eyelid position hasn't been saved.");
                if ( false == isEyelidBlendshapeLookDownSet )
                    throw new System.Exception("The eyes look down eyelid position hasn't been saved.");
            }
        }
开发者ID:ralphlizard,项目名称:HotPatata,代码行数:48,代码来源:ControlData.cs

示例12: GetModelBoneLength

    private bool GetModelBoneLength(Animator animatorComponent, HumanBodyBones baseJoint, HumanBodyBones endJoint, ref float length)
    {
        length = 0f;

        if(animatorComponent)
        {
            Transform joint1 = animatorComponent.GetBoneTransform(baseJoint);
            Transform joint2 = animatorComponent.GetBoneTransform(endJoint);

            if(joint1 && joint2)
            {
                length = (joint2.position - joint1.position).magnitude;
                return true;
            }
        }

        return false;
    }
开发者ID:lukasIO,项目名称:UnityMyo,代码行数:18,代码来源:AvatarScaler.cs

示例13: GetModelBodyHeight

    private bool GetModelBodyHeight(Animator animatorComponent, ref float height)
    {
        height = 0f;

        if(animatorComponent)
        {
            //Transform hipCenter = animatorComponent.GetBoneTransform(HumanBodyBones.Hips);

            Transform leftUpperArm = animatorComponent.GetBoneTransform(HumanBodyBones.LeftUpperArm);
            Transform rightUpperArm = animatorComponent.GetBoneTransform(HumanBodyBones.RightUpperArm);

            Transform leftUpperLeg = animatorComponent.GetBoneTransform(HumanBodyBones.LeftUpperLeg);
            Transform rightUpperLeg = animatorComponent.GetBoneTransform(HumanBodyBones.RightUpperLeg);

            if(leftUpperArm && rightUpperArm && leftUpperLeg && rightUpperLeg)
            {
                Vector3 posShoulderCenter = (leftUpperArm.position + rightUpperArm.position) / 2;
                Vector3 posHipCenter = (leftUpperLeg.position + rightUpperLeg.position) / 2;  // hipCenter.position

                height = (posShoulderCenter.y - posHipCenter.y);

                return true;
            }
        }

        return false;
    }
开发者ID:lukasIO,项目名称:UnityMyo,代码行数:27,代码来源:AvatarScaler.cs

示例14: Awake

 void Awake()
 {
     healthDisplay = transform.Find("Health").GetComponent<TextMesh>();
     anim = GetComponent<Animator>();
     Transform rightHand = anim.GetBoneTransform(HumanBodyBones.RightHand);
     saber = rightHand.Find("LSaber/Beam").gameObject;
     saberCont = rightHand.GetComponentInChildren<SaberController>();
     rb = GetComponent<Rigidbody>();
     health = MAX_HEALTH;
 }
开发者ID:lmucs,项目名称:Coliseo,代码行数:10,代码来源:Actor.cs

示例15: Initialize

    public void Initialize(InstantVR ivr, BodySide bodySide, IVR_BodyMovements bodyMovements) {
        this.ivr = ivr;

        this.bodySide = bodySide;
        animator = ivr.GetComponentInChildren<Animator>();

        if (bodySide == BodySide.Left) {
            upperArm = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.LeftHand);
        } else {
            upperArm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
            forearm = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
            hand = animator.GetBoneTransform(HumanBodyBones.RightHand);
        }

        upperArmLength = Vector3.Distance(upperArm.position, forearm.position);
        forearmLength = Vector3.Distance(forearm.position, hand.position);
        length = upperArmLength + forearmLength;
        if (length == 0)
            Debug.LogError("Avatar arm positions are incorrect. Please restore avatar in T-pose.");

        upperArmLength2 = upperArmLength * upperArmLength;
        forearmLength2 = forearmLength * forearmLength;

        upperArmStartPosition = upperArm.position;
    }
开发者ID:ys27,项目名称:wearhacks2016,代码行数:27,代码来源:IVR_BodyMovements.cs


注:本文中的UnityEngine.Animator.GetBoneTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。