12 第1页 | 共2 页下一页
返回列表 发新帖
查看: 2792|回复: 11
打印 上一主题 下一主题

[经验分享] 角色动画中的细节动画的实现

[复制链接]

5472

主题

6

听众

1万

积分

版主

Rank: 7Rank: 7Rank: 7

纳金币
76544
精华
23

活跃会员 荣誉管理 突出贡献 优秀版主 论坛元老

跳转到指定楼层
楼主
发表于 2011-11-23 17:28:00 |只看该作者 |倒序浏览


           很详细很不错的关于角色动画设置及导出到unity3d中进行控制的详细教程,推荐阅读!
           

           This is a tutorial on getting bones that are part of an animated skeleton to be controlled by Unity’s physics system rather than animation, i.e. ragdoll or jiggle bones. It took me a while to figure out the specifics of getting it working.
         

           This method will also work with 3ds max Bipeds Twist bones, which rely on the animation being fully baked.
         

           Click on any of the images for a larger version.
         

           setting up in 3ds max
           




            
         

           Set up and skin your rig as you usually would. Include any bones you would like to be jiggle bones and attach them into the skeleton’s hierarchy as normal.
         

           In my case, I have some dangling belt attachments and my characters ponytail intended to be jiggle bones.
         

            the key to jiggle bones
         

           The important thing to note is that, while all of my regular bones are keyframed into the T-Pose, the jiggle bones do not have keyframes. They are positioned correctly but they are not keyframed into position.
         

           It is imperative that the jiggle bones remain unkeyframed throughout your T-Pose and all of your animations. One keyframe anywhere in there and the animation system takes control over the physics and you’ve just got regular skeletal animation again.
           

            
         






           exporting the t-pose
         

           When exporting the t-pose, select your mesh(es) and your bones, including your twist bones and including the bones that you want to be jiggle bones.
         

           Go to Export > Export Selected and choose FBX as the format.
           

            
         






           Ensure that you do not export animation at this point – we only want the model, it’s bones and the skinning information. Chosing animation export here will mean that it gives keyframed positions to our jiggle bones, which stops them being jiggle bones.
           






            exporting animations
         

           When using Bipeds Twist bones, they are not keyframed directly and so have to have the animation fully baked out.
         

           The problem arises here, because baking the animation also means that any jiggle bones get keyframes assigned. Disaster!
         

           What do we do? Simple – don’t export the jiggle bones at all when exporting animation.
         

           This is where Export Selected comes into play again. We simply select everything we did in the T-Pose export except the jiggle bones. Unity will simply find that the jiggle bones aren’t in the exported animation and won’t attempt to apply the animation to our jiggle bones.
         

           To this end, I find it easier to keep the jiggle bones in their own layer that I keep frozen. Which stops me accidentally moving, selecting or keyframing them.
           

            
         






           So, once you have selected everything you want exported (except the jiggle bones, of course), go once again to Export > Export Selected and choose FBX as the format.
         

           This time the filename’s the Unity animation  standard of [modelName]@[animationName].fbx.
         

           Ensure you tick the box marked Bake, or your twist bones won’t be exported.
           

            
         




           setting up in unity
         

           Now the jiggle bones are in and unkeyframed, hooking them up to the physics engine is the same process as you would set up any ragdolled joint, but I’ll***n through the process anyway.
         

           the parent bone
         

           The parent bone should be whichever bone your jiggle bone is attached to. First up, drag your model into the scene then find and select the parent bone in the project hierarchy.
         

           Apply a rigidbody to your parent bone. Set it to be Kinematic and uncheck Apply Gravity.
         

           Apply a collider to your parent bone and set up it’s scale and alignment so that it fits the mass of the vertices the bone has influence over.
           

            
         






           the jiggle bone
         

           Jump down the hierarchy in the project pane and select the bone you want to be a jiggle bone.
         

           Again, apply a rigidbody but this time ensure Kinematic is unchecked and Apply Gravity is checked. Set the mass and drag to fit the material and size of whatever your jiggle bone is.
         

           Apply a collider and set it’s scale and alignment to fit your jiggle bone.
         

           Now apply a physics joint. Any kind will work but in this instance I’m using a Character Joint. Set the Connected Body to be the same Rigidbody component you just applied to the parent bone. Set up the constraints of your physics joint to be what you like.
           

            
         






           other bones
         

           In some cases, you will want other parts of your model to collide with your jiggle bone. In my case, I want both of my characters thighs to be able to knock the belt attachments around as she***ns.
         

           For each of these bones, repeat the process we used in the parent bone of attaching a kinematic rigidbody and collider.
           

            
         






           final touches
         

           So, now we should have rigidbodied bones that succumb to gravity and collide with other bones as they move via skeletal animation.
         

           But you’ll notice that as your character moves around the world, they don’t get affected by momentum, they just sit there hanging down.
         

           There are two possible solutions to this;
         

           1) In your models Animation component in the inspector, there’s a tickbox for “Animate Physics”, which may work for you but I found this gives very jittery, erratic results. So, as a solution…
         

           2) Use a little script to get the movement of the parent bone and apply it as a force to the rigidbody. Create a new Java Script and copy this code into it then apply it to each of your jiggle bones;
         

           #pragma strict
         

           private var thisParent : Transform;
         

           private var thisRigidbody : Rigidbody;
         

           private var parentPosLastFrame : Vector3 = Vector3.zero;
         

           function Awake () {
         

           thisParent = transform.parent;
         

           thisRigidbody = transform.GetComponent.< Rigidbody > ();
         

           }
         

           function Update () {
         

           thisRigidbody.AddForce ( ( parentPosLastFrame - thisParent.position ) * 100 );
         

           parentPosLastFrame = thisParent.position;
         

           }
         

           finished!
           

            
         
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

沙发
发表于 2012-1-27 23:26:28 |只看该作者
对你的思念象袅袅的轻烟不绝如缕,对你的祝福是潺潺的小溪叮咚作响。或许岁月将往事褪色,或许空间将彼此隔离。但值得珍惜的依然是你给我的情谊。再次对你说声:新年快乐!
回复

使用道具 举报

462

主题

1

听众

31万

积分

首席设计师

Rank: 8Rank: 8

纳金币
2
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

板凳
发表于 2012-5-25 23:19:09 |只看该作者
加精、加亮滴铁子,尤其要多丁页丁页
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

地板
发表于 2012-6-16 23:25:26 |只看该作者
路过、路过、快到鸟,列位请继续...ing
回复

使用道具 举报

tc    

5089

主题

1

听众

33万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

5#
发表于 2012-9-19 23:19:04 |只看该作者
其实楼主所说的这些,俺支很少用!
回复

使用道具 举报

tc    

5089

主题

1

听众

33万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

6#
发表于 2012-10-14 23:18:05 |只看该作者
响应天帅号召,顶
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

7#
发表于 2013-2-15 23:22:01 |只看该作者
“再次路过……”我造一个-----特别路过
回复

使用道具 举报

nts    

3

主题

1

听众

743

积分

初级设计师

Rank: 3Rank: 3

纳金币
7
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

8#
发表于 2013-10-17 11:03:15 |只看该作者
文章极好,就是有的地方看不懂
回复

使用道具 举报

1

主题

1

听众

4795

积分

中级设计师

Rank: 5Rank: 5

纳金币
955
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

9#
发表于 2014-2-24 02:07:51 |只看该作者
谢谢分享
回复

使用道具 举报

0

主题

1

听众

2286

积分

中级设计师

Rank: 5Rank: 5

纳金币
0
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

10#
发表于 2014-2-24 10:45:33 |只看该作者
感谢分享
回复

使用道具 举报

12 第1页 | 共2 页下一页
返回列表 发新帖
您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-5-10 15:50 , Processed in 0.114483 second(s), 28 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部