1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TestHandPoint : MonoBehaviour
- {
- public Transform leftHand;
- public Transform rightHand;
- private Animator playerAni;
- public Animator PlayerAni
- {
- get
- {
- if (!playerAni)
- {
- playerAni = GetComponent<Animator>();
- }
- return playerAni;
- }
- }
- private void OnAnimatorIK(int layerIndex)
- {
- if (PlayerAni)
- {
- PlayerAni.SetIKPositionWeight(AvatarIKGoal.RightHand, 1f);
- PlayerAni.SetIKRotationWeight(AvatarIKGoal.RightHand, 1f);
- //设置左手骨骼的ik目标为胶囊体的坐标和旋转
- PlayerAni.SetIKPosition(AvatarIKGoal.RightHand, rightHand.position);
- PlayerAni.SetIKRotation(AvatarIKGoal.RightHand, rightHand.rotation);
- PlayerAni.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1f);
- PlayerAni.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1f);
- //设置左手骨骼的ik目标为胶囊体的坐标和旋转
- PlayerAni.SetIKPosition(AvatarIKGoal.LeftHand, leftHand.position);
- PlayerAni.SetIKRotation(AvatarIKGoal.LeftHand, leftHand.rotation);
- }
- }
- }
|