新增盾牌
1.在玩家左手添加weaponHandle,再添加一个盾牌的模型。
2.给BaseLayer勾选IKPass,这样BaseLayer就会调用OnAnimatorIK的事件
3.通过Animator抓某个骨头的组件,这里抓左Arm
private Animator anim;
private void Awake()
{
anim = GetComponent<Animator>();
}
private void OnAnimatorIK(int layerIndex)
{
Transform leftArm = anim.GetBoneTransform(HumanBodyBones.LeftLowerArm);
}
4.通过改变BoneTransform来改变左胳膊,让角色再Idle状态和举盾状态进行区分,又去SetBoneLocalRotation只能用四元数,我们这里要将localEulerAngles转换成一个Quaternion
private Animator anim;
public Vector3 armAddEuler;
private void Awake()
{
anim = GetComponent<Animator>();
}
private void OnAnimatorIK(int layerIndex)
{
Transform leftLowerArm = anim.GetBoneTransform(HumanBodyBones.LeftLowerArm);
leftLowerArm.localEulerAngles += armAddEuler;
anim.SetBoneLocalRotation(HumanBodyBones.LeftLowerArm, Quaternion.Euler(leftLowerArm.localEulerAngles));
}
5.给weapon添加一个新的layer,在PhysicsManager中将weapon的碰撞进行管理,这里至少让weapon与ground不进行碰撞检测
网友评论