using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour
{
Animator a;
public Transform zuo;//事先放好左手位置及角度
public Transform you;//事先放好右手位置及角度
void Start()
{
a = GetComponent<Animator>();
{
a.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
a.SetIKPosition(AvatarIKGoal.LeftHand, zuo.position);
a.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
a.SetIKRotation(AvatarIKGoal.LeftHand, zuo.rotation);
a.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
a.SetIKPosition(AvatarIKGoal.RightHand, you.position);
a.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
a.SetIKRotation(AvatarIKGoal.RightHand, you.rotation);
}
using System.Collections;
public class Move : MonoBehaviour
{
Animator a;
public Transform zuo;//事先放好左手位置及角度
public Transform you;//事先放好右手位置及角度
void Start()
{
a = GetComponent<Animator>();
}
{
a.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
a.SetIKPosition(AvatarIKGoal.LeftHand, zuo.position);
a.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
a.SetIKRotation(AvatarIKGoal.LeftHand, zuo.rotation);
a.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
a.SetIKPosition(AvatarIKGoal.RightHand, you.position);
a.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
a.SetIKRotation(AvatarIKGoal.RightHand, you.rotation);
}
本文介绍了一个Unity中的IK(Inverse Kinematics)系统应用实例,通过控制角色的左右手到达指定的位置和旋转状态,实现自然的手部动画效果。此脚本适用于Unity游戏开发中需要精确控制角色肢体的情况。
774

被折叠的 条评论
为什么被折叠?



