Add Shield(新增盾牌)

在手腕或者手肘下面新增空对象(weaponhandle)下面新建一个cube盾牌,再调的时候注意穿模问题;
当你的盾牌加上去之后,会出现问题:当你在待机状态的时候盾牌是在防御状态的,这时候就需要让美术师调整模型,或者里用程式码微调模型;
利用程式码调整动画:IK Pass(当你上勾的时候引擎才会帮你调用OnAnimatorIK() )在Base Layer上将IK Pass勾选 增加LeftArmAnimFix脚本,再此脚本中调用OnAnimatorIK() 在这个函数中找到小臂这跟骨头,并将它给一个角度让产生一个角度

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LeftArmAnimFix : MonoBehaviour {
    private Animator anim;
    public Vector3 a;

    private void Awake()
    {
        anim = GetComponent<Animator>();
    }
    private void OnAnimatorIK()
    {
        Transform leftLowerArm = anim.GetBoneTransform(HumanBodyBones.LeftLowerArm);//找到哪个骨头
        leftLowerArm.localEulerAngles +=0.75f* a;//加角度
        anim.SetBoneLocalRotation(HumanBodyBones.LeftLowerArm,Quaternion.Euler(leftLowerArm.localEulerAngles));//将旋转量写回去
    }

}

这时候会产生一个问题:当盾牌和地面碰撞的时候会以为盾牌的碰撞框和地面发生物理碰撞,摄影机会疯狂抖动。解决这个问题:新增一个Layer(weapon)将weapon层和ground层不进行物理运算(Edit>>project settings>>physics)将里面weapon的碰撞只保留weapon和weapon的碰撞。

猜你喜欢

转载自blog.csdn.net/weixin_44025382/article/details/86534133
Add
今日推荐