当前位置: 首页 > wzjs >正文

专科网站建设论文中国十大网站

专科网站建设论文,中国十大网站,广州网站seo,陕西省住房城乡建设厅网站管理中心目录 1 正向动力学和反向动力学 1.1 正向动力学 1.2 反向动力学 1.3 实现目标 2 实现反向动力 2.1 先定义一个目标 2.2 动画层layer,需要加 IK pass 2.3 增加头部朝向代码 2.3.1 专门的IK方法 OnAnimatorIK(int layerIndex){} 2.3.2 增加朝向代码 2.4 …

目录

1 正向动力学和反向动力学

1.1 正向动力学

1.2 反向动力学

1.3 实现目标

2 实现反向动力

2.1  先定义一个目标

2.2 动画层layer,需要加 IK pass

2.3 增加头部朝向代码

2.3.1 专门的IK方法  OnAnimatorIK(int layerIndex){}

2.3.2 增加朝向代码

2.4 增加头部朝向代码

2.5  需要设置权重

2.6 需要设置位置position 和 rotation

2.7 具体代码: 头部和手都实现了IK朝向


1 正向动力学和反向动力学

1.1 正向动力学

  • 正常的模型身体的运动
  • 模仿人体的真实的骨骼。

1.2 反向动力学

  • 真实世界中,不存在的,相反的一个骨骼方式
  • 用目标---牵引 手指---牵引手臂,这样反向的指引方式
  • 游戏里IK相关的就是

1.3 实现目标

  • 想实现,玩家角色的眼睛,头部,手,一直指向目标

2 实现反向动力

2.1  先定义一个目标

public class TestPlayer1 : MonoBehaviour

{

    public Transform target1;

    private Animator animator1;

2.2 动画层layer,需要加 IK pass

  • 需要进行反向动力学的动画层,
  • 动画层layer,需要加 IK pass

2.3 增加头部朝向代码

2.3.1 专门的IK方法  OnAnimatorIK(int layerIndex){}

  • 需要专门的IK方法 
  • private void OnAnimatorIK(int layerIndex){}

2.3.2 增加朝向代码

  • animator1.SetLookAtWeight(1);
  • animator1.SetLookAtPosition(target1.position);

    private void OnAnimatorIK(int layerIndex)

    {

        //设置头部IK  Weight=0表示不生效

        animator1.SetLookAtWeight(1);

        animator1.SetLookAtPosition(target1.position);

    }

2.4 增加头部朝向代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class TestPlayer1 : MonoBehaviour
{public Transform target1;private Animator animator1;// Start is called before the first frame updatevoid Start(){animator1=GetComponent<Animator>();}// Update is called once per framevoid Update(){float horzontal=Input.GetAxis("Horizontal");float vetical=Input.GetAxis("Vertical");Vector3 dir1=new Vector3(horzontal,0,vetical);Debug.DrawRay(transform.position,dir1,Color.red);//如果按下了移动按键if(dir1 != Vector3.zero){//面向向量transform.rotation=Quaternion.LookRotation(dir1);//播放跑步动画animator1.SetBool("IsRun",true);//朝着面向的前方移动transform.Translate(Vector3.forward*2*Time.deltaTime);}else{//播放walk动画animator1.SetBool("IsRun",false);}if(Input.GetKeyDown(KeyCode.Q)){//触发wave参数GetComponent<Animator>().SetTrigger("wave");}//获得曲线的test1参数//Debug.Log(animator1.GetFloat("test1"));}void rightfoot(){Debug.Log("右脚");}void leftfoot(){Debug.Log("左脚");}private void OnAnimatorIK(int layerIndex){//设置头部IK  Weight=0表示不生效animator1.SetLookAtWeight(1);animator1.SetLookAtPosition(target1.position);}}

2.5  需要设置权重

  • 权重=1 表示生效
  • animator1.SetIKPositionWeight(AvatarIKGoal.RightHand,1);
  • animator1.SetIKRotationWeight(AvatarIKGoal.RightHand,1);

       

   private void OnAnimatorIK(int layerIndex)

    {

        //设置头部IK  Weight=0表示不生效

        animator1.SetLookAtWeight(1);

        animator1.SetLookAtPosition(target1.position);

        //设置右手position的IK权重

        animator1.SetIKPositionWeight(AvatarIKGoal.RightHand,1);

        //设置右手旋转IK权重

        animator1.SetIKRotationWeight(AvatarIKGoal.RightHand,1);

        //设置右手IK

        animator1.SetIKPosition(AvatarIKGoal.RightHand,target1.position);

        animator1.SetIKRotation(AvatarIKGoal.RightHand,target1.rotation);

    }

2.6 需要设置位置position 和 rotation

  • //设置右手IK
  • animator1.SetIKPosition(AvatarIKGoal.RightHand,target1.position);
  • animator1.SetIKRotation(AvatarIKGoal.RightHand,target1.rotation);

2.7 具体代码: 头部和手都实现了IK朝向

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class TestPlayer1 : MonoBehaviour
{public Transform target1;private Animator animator1;// Start is called before the first frame updatevoid Start(){animator1=GetComponent<Animator>();}// Update is called once per framevoid Update(){float horzontal=Input.GetAxis("Horizontal");float vetical=Input.GetAxis("Vertical");Vector3 dir1=new Vector3(horzontal,0,vetical);Debug.DrawRay(transform.position,dir1,Color.red);//如果按下了移动按键if(dir1 != Vector3.zero){//面向向量transform.rotation=Quaternion.LookRotation(dir1);//播放跑步动画animator1.SetBool("IsRun",true);//朝着面向的前方移动transform.Translate(Vector3.forward*2*Time.deltaTime);}else{//播放walk动画animator1.SetBool("IsRun",false);}if(Input.GetKeyDown(KeyCode.Q)){//触发wave参数GetComponent<Animator>().SetTrigger("wave");}//获得曲线的test1参数//Debug.Log(animator1.GetFloat("test1"));}void rightfoot(){Debug.Log("右脚");}void leftfoot(){Debug.Log("左脚");}private void OnAnimatorIK(int layerIndex){//设置头部IK  Weight=0表示不生效animator1.SetLookAtWeight(1);animator1.SetLookAtPosition(target1.position);//设置右手position的IK权重animator1.SetIKPositionWeight(AvatarIKGoal.RightHand,1);//设置右手旋转IK权重animator1.SetIKRotationWeight(AvatarIKGoal.RightHand,1);//设置右手IKanimator1.SetIKPosition(AvatarIKGoal.RightHand,target1.position);animator1.SetIKRotation(AvatarIKGoal.RightHand,target1.rotation);}}

http://www.dtcms.com/wzjs/520428.html

相关文章:

  • 轻松seo优化排名 快排江苏seo推广
  • 反腐网站建设的目的查域名的网址
  • 如何做下载网站长沙网站建站模板
  • 网站设计与建设课程2022今天刚刚发生地震了
  • 网站做填充友情链接什么意思
  • 做家具的外国网站网络优化需要哪些知识
  • 哪里能找到免费网站百度云登录入口
  • 士兵突击网站怎么做小说百度风云榜
  • 新乡 网站开发百度推广怎么提高关键词排名
  • 百度站长平台快速收录怎么弄推广网站有哪些
  • 网站主体备案信息查询互联网营销师培训多少钱
  • 传媒公司网站模板网站策划是做什么的
  • 舆情报告分析案例百度seo关键词优化费用
  • 用什么软件做网站最好梧州网站seo
  • 重庆品牌网站建设公司排名搜索引擎查重
  • 运营网站开发工作网站快速刷排名工具
  • 网上书店网网站建设企业培训计划
  • 怎么建设独立网站网络营销案例分析ppt
  • 给自己的网站起名字新闻头条国内大事
  • 招商加盟网站大全汇总2023年8月份新冠病毒
  • 长丰县住房和建设局网站seo是什么字
  • 国家高新技术企业牌匾seo是什么部门
  • 苏醒主题做的网站怎样做网络推广效果好
  • logo一键生成器免费版原型图西安百度网站快速优化
  • 沈阳做网站大约要多少钱关键词推广哪家好
  • 上海机电设备公司网站建设兰州百度推广的公司
  • 公司网站建设合同模板seo搜索引擎优化知乎
  • wordpress google cdn南京seo网络推广
  • 深圳公司做网站企业网络营销成功案例
  • 美食网站开发的目标微信如何投放广告