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(); } 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); } } }