Unity IK(反向运动学)初探
http://blog.csdn.net/myarrow/article/details/44450199
1. 简介
IK与FK对应,正向运动学就是根骨骼带动节点骨骼运动。而反向运动学就是反过来,由子节点带动父节点运动。
2. 实例
对于Humanoid的动画,使用的方法很简单,在Animator窗口中,对于要使用IK的动画状态勾上Foot IK选项,在Base Layer中勾上IK Pass选项。然后在代码中实现OnAnimatorIK函数来控制IK。
其实例代码如下所示(IKCtrl.cs):
- using UnityEngine;
- using System.Collections;
- using System;
- [RequireComponent(typeof(Animator))]
- public class IKCtrl : MonoBehaviour {
- protected Animator animator;
- public bool isActive = false;
- public Transform rightHandObj = null;
- private bool isFirst = true;
- // Use this for initialization
- void Start () {
- Debug.Log ("Start is being called");
- animator = GetComponent<Animator> ();
- }
- // a callback for calc IK, when Mecanim run, Animator will call this callback
- void OnAnimatorIK(int layerIndex) {
- Debug.Log ("OnAnimatorIK is being called");
- if (animator) {
- // if the IK is active, set the position and rotation directly to the goal
- if(isActive){
- // weight =1.0 for the right hand means position and rotation will be at the IK goal(the place the character wants to grab)
- animator.SetIKPositionWeight(AvatarIKGoal.RightHand,1.0f);
- animator.SetIKRotationWeight(AvatarIKGoal.RightHand,1.0f);
- // set the position and the rotation of the rihgt hand where the external object is
- if(rightHandObj != null){
- Debug.Log ("Set Avatar's position and rotation");
- animator.SetIKPosition(AvatarIKGoal.RightHand,rightHandObj.position);
- animator.SetIKRotation(AvatarIKGoal.RightHand,rightHandObj.rotation);
- }else{
- animator.SetIKPositionWeight(AvatarIKGoal.RightHand,0);
- animator.SetIKRotationWeight(AvatarIKGoal.RightHand,0);
- }
- }
- }
- }
- }
3. 动画制作要点
3DS Max中使用IK的情景还是非常多的。比如一个小章鱼,每个脚上面绑上IK,然后就可以通过脚步移动控制整条腿的运动。如果不用IK的话操作起来很麻烦而且不自然。
而FBX的格式里面也是有IK信息的。只是Unity过滤了相关的数据而已。美术在导出动画之前做这么的操作,然后动画就正常了。
1) Set up the bone structure as you please.
2) Create the animations you want, using FK and/or IK
3) Select all bones and/or IK solvers
4) Go to Motion->Trajectories and press Collapse. Unity makes a key filter, so the amount of keys you export is irrelevant
5) "Export" or "Export selected" as newest FBX format
6) Drop the FBX file into Assets as usual
在3dmax中ctrl+A选中所有所有骨骼,在右侧的选项卡中选择Motion->Trajectories,如果已经选择好骨骼,Collapse按钮就可以正常点击,点击这个按钮,然后正常的导出动画。这样Unity中的动画表现就跟3dmax一致了。
注意,使用Collapse功能会修改动画的帧(使帧间隔变得一样),这样我们很多动作播放的时候就会被改变,比如攻击动作会变得很慢,没有力度。美术应该在Collapse后再次修改动画(或者是在制作动画之前使用Collapse)以保证动画的正确性。
参考:http://blog.csdn.net/langresser_king/article/details/22725499
Unity IK(反向运动学)初探的更多相关文章
- 【Unity Shaders】初探Surface Shader背后的机制
转载请注明出处:http://blog.csdn.net/candycat1992/article/details/39994049 写在前面 一直以来,Unity Surface Shader背后的 ...
- Unity 摄像机旋转初探
接触打飞机的游戏时都会碰见把摄像机绕 x 轴顺时针旋转 90°形成俯瞰的视角的去看飞船.也没有多想,就感觉是坐标系绕 x 轴旋转 90°完事了.但是昨天用手比划发一下发现不对.我就想这样的话绕 x 轴 ...
- 分享一个大神自己的blog
std::sort() 详解 http://feihu.me/blog/ C++11 新特性 http://blog.guoyb.com/2016/09/19/cpp11-all/ unity3d 相 ...
- Unity给力插件之Final IK
Final IK细节: 1.Aim IK:设定一个目标,关节末端始终朝向该目标,一般用来做头部的朝向. 步骤: a.在模型头节点处添加Aim空物体并reset b.给模型添加Aim IK组件,并填上A ...
- AnimatorController反向运动学IK
通过使用反向运动学IK,我们可以根据需要控制角色身体某个特定部位进行旋转或移动,达到想要的一些效果,比如:在移动时,让一只脚带伤拖行:让手抬起去拿桌上的苹果:让脑袋一直面向我们的色像机,就像一直注视着 ...
- 基于Unity的AR开发初探:第一个AR应用程序
记得2014年曾经写过一个Unity3D的游戏开发初探系列,收获了很多好评和鼓励,不过自那之后再也没有用过Unity,因为没有相关的需求让我能用到.目前公司有一个App开发的需求,想要融合一下AR到A ...
- unity初探之黑暗之光(2)
unity初探之黑暗之光(2) 一.设置角色跟随鼠标点击移动 思路:使用charactercollider的SimpleMove方法来控制角色的移动.通过摄像机的射线投射到地面,通过屏幕上的一个点也就 ...
- Unity初探之黑暗之光(1)
Unity初探之黑暗之光(1) 1.镜头拉近 public float speed=10f;//镜头的移动速度 ;//镜头的结束位置 // Update is called once per fram ...
- Unity初探—SpaceShoot
Unity初探—SpaceShoot DestroyByBoundary脚本(C#) 在游戏中我们添加了一个Cube正方体,让他来作为游戏的边界.它是可以触发触发事件的(勾选Is Trigger),当 ...
随机推荐
- Leetcode 001-twosum
#Given an array of integers, return indices of the two numbers such that they add up to a specific t ...
- mybatis学习总结(三)——增删查改
映射器是mybatis的基础和核心,下面学习下映射器的使用 映射器的主要元素 select 查询语句,可以自定义参数和返回结果集 insert 插入语句,返回一个整数,代表插入的条数 update ...
- 九度OJ 1124:Digital Roots(数根) (递归)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2963 解决:1066 题目描述: The digital root of a positive integer is found by s ...
- 可以执行全文搜索的原因 Elasticsearch full-text search Kibana RESTful API with JSON over HTTP elasticsearch_action es 模糊查询
https://www.elastic.co/guide/en/elasticsearch/guide/current/getting-started.html Elasticsearch is a ...
- HttpURLConnection访问网络
HttpURLConnection是一个抽象类,获取HttpURLConnection对象HttpURLConnection urlConnection=new URL(http://www.baid ...
- [自动化平台系列] - 初次使用 Macaca-前端自动化测试(1)
1. 所先看一下官方地址,了解一下这个是不是你想要的测试工具 https://macacajs.github.io/macaca/environment-setup.html 2. 去掉sudo -- ...
- HTML中级教程 元标签
元标签对浏览器窗口中的内容不做任何事情,它们用在关于页面的像搜索引擎的归类目录信息中. 元标签meta可以使用尽可能多次如你所需,包括内容属性content(必须的).名称属性name和http-eq ...
- HDU2147 kiki's game (SG表找规律)
Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes th ...
- mysql审计实现方法
Mysql版本: 5.6.24-72.2 一.通过init-connect + binlog 实现MySQL审计功能 基本原理: 由于审计的关键在于DML语句,而所有的DML语句都可以通过binlog ...
- MSTAR SERVICE结构
程序结构: 1.主线程的构建 appMain.c/appMain_Create(): 2.主线程服务构建 _appMain_Task() 清空服务: memset(_appMain.appList, ...
