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),当 ...
随机推荐
- Android-可随意拖动的View
http://blog.csdn.net/w8320273/article/details/8101687
- html中设置透明遮罩层的兼容性代码
说明:下面遮罩层的height视实际情况自行修改,要求显示的div层的样式需加上position:relative,位于遮罩层层div的下面一行.<div id="ceng" ...
- 51NOD 1962 区间计数 单调栈+二分 / 线段树+扫描线
区间计数 基准时间限制:1.5 秒 空间限制:262144 KB 分值: 80 两个数列 {An} , {Bn} ,请求出Ans, Ans定义如下: Ans:=Σni=1Σnj=i[max{ ...
- MSVC环境,Qt代码包含中文无法通过构建的解决方案
将代码文件的编码更改为ANSI(方便起见,将Qt Creator的Text Editor默认编码改为System) 这样就可以通过构建,不过会出现中文乱码的问题 还需要使用QStringLiteral ...
- Exam 70-762 Developing SQL Databases
这个考试还是很有用的,教了很多有用的东西,不错,虽然考试需要很多钱,不过值的尝试.虽然用了sql server 这么多年但是对于事务.多并发的优化还是处于小学生的水平,通过这次考试争取让自己提一个档次 ...
- 我所认为的KVC和KVO
引子: 为什么要写这个,只是突然一个念头闪现,说一下本人目前理解.KVC: Key-value coding,它是一种使用字符串标识符,间接访问对象属性的机制.但是关就这一 ...
- Linux下Redis C++操作的封装
安装和启动Redis服务...略!很粗糙的版本,待改进... Redis Client C++示例代码...略! /** * Time: 14-3-10 * File: RedisCache.h * ...
- 牛逼的This使用
今天看到一个很不错的this使用demo: package com.toov5.Reordering; class Message1{ private Channel channel; private ...
- 使用libcurl进行HTTP GET操作
Working example how to do a GET request with libcurl and save it to a string variable for future use ...
- the art of seo(chapter one)
preface:Andy Johns (@ibringtraffic):growth strategist@Wealthfront ***1.Search Reflecting Consciousne ...
