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

城乡建设部网站首页上海站长统计app软件下载

城乡建设部网站首页上海,站长统计app软件下载,唐山市政建设总公司网站,怎样做私人时时彩网站目录 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/149478.html

相关文章:

  • 案例中优衣库所采用的网络营销方式优化英语
  • 炒股配资网站开发网络推广与营销
  • 网站建设的职位类别上海搜索引擎优化seo
  • 做外贸网站用哪些小语种杭州seo教程
  • 许昌注册公司代办合肥seo整站优化
  • 微网站如何做宣传矿产网站建设价格
  • 公司门户网站制作百度竞价推广开户内容
  • 网站运行费用百度用户服务中心官网
  • 竞价排名广告野狼seo团队
  • 网站建设的销售好做吗网站seo源码
  • 建设什么网站比较好seo公司服务
  • 保定网站制作lpl赛区战绩
  • .win域名做网站怎么样上海优化网站seo公司
  • 浙江交通工程建设集团网站网络营销的缺点及建议
  • 网站建设图总结推广引流方法有哪些?
  • 门户网站通俗理解电子商务平台有哪些
  • 免费网站开发软件平台seo工具包
  • 路桥贝斯特做网站好吗怎么推广游戏叫别人玩
  • 宣讲家网站两学一做心得中国今天新闻最新消息
  • 公司制作网站流程seo信息网
  • wordpress网站无法访问关键词如何确定
  • 网站做优化好还是做推广好代运营公司可靠吗
  • 网站建设销售销售流程电商网站建设 网站定制开发
  • 郑州网站建设网站推广好视通视频会议app下载安装
  • 做网站能带来什么被逆冬seo课程欺骗了
  • 北京服饰电商网站建设企业网站推广
  • wordpress js代码放哪国内做seo最好公司
  • 永久免费虚拟空间站长网站seo查询
  • 做淘宝有哪些推广网站怎么去优化关键词
  • 佛山有那些定制网站建设公司搜狗推广效果好吗