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

unity3d动作事件运用(二)

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

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

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



            Setting Animation Events
            




           Once you have your animation state selected ( I have the walk animation state selected), you can begin adding events. If you bring up Scene view behind, you can see your model actually moving when you s***b the timeline. See below image.
         

            
           


           Where to put the animation events
         

           Once you s***b your animation to know where you want an event. You can create an event there (right most icon on the play toolbar). If you select the event, you will notice that there are no options for what it wants to do. We will do that next.
         


            Binding functions to Events
            




           In order for the animation events to to fire off a function for an event, it needs to know where it is. The way animation events work, there has to be a script attached to the gameobject that has the animation component as well. See below.
         

            
           






           Adding a script for animation events
         

           I added a script to the same place the animation component is. You can create functions in there and that is what the animation window tool will see.
         

           public void walkAnimationEvent()
         

           {
         

           Debug.Log("Foot is down walking");
         

           audio.PlayOneShot(walkSound);
         

           audio.volume = 0.4f;
         

           }
         

           Once you add a function like the one above, you can go back to your animation window and select the event again. This time your new function will show up. When you***n the game now, you will see that the event will fire every time the animation hits that frame. Success!
         

            
         

           Extra Credit
           

           Looping animations such as walking are a little more complicated from what I have done with them. Since they are looping, sometimes the fire off more than they should. To solve it, I have add an enum that has what animation state the character is in. It will only do the function if it is firing AND if it is in the right state. You can download the “Witch Training Project” to see if you are interested. It still needs a little tweaking since the walk sound lingers a little too long – but you the idea
           

           I haven’t seen this in-depth of animation events on many blog posts, so hopefully this will help in understanding and using them in your project. Happy game making!
         

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

使用道具 举报

462

主题

1

听众

31万

积分

首席设计师

Rank: 8Rank: 8

纳金币
2
精华
0

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

沙发
发表于 2012-1-19 22:58:48 |只看该作者
秋天的落叶已飘远,冬日的暖阳已降临,春天的故事在萌芽,夏日的清凉在期待。新年的钟声提前为你敲响,HAPPYNEWYEAR!
回复

使用道具 举报

5969

主题

1

听众

39万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
0

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

板凳
发表于 2012-1-20 23:30:06 |只看该作者
林志玲,娇滴滴,祝你新年一定要好好的啦!小沈阳,笑嘻嘻,祝你新年一定要杠杠的哈!春晚群星,闹哄哄的,祝你新年辞旧迎新开创新纪元!
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

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

地板
发表于 2012-1-26 23:26:03 |只看该作者
笑声,欢天喜地;幸运,铺天盖地;才情,经天纬地;财气,呼天唤地;豪气,遮天盖地;福气,惊天动地;春节,冰天雪地;快乐,翻天覆地!
回复

使用道具 举报

tc    

5089

主题

1

听众

33万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
0

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

5#
发表于 2012-3-8 23:24:32 |只看该作者
百度的叫度娘,网易的叫易娘,新浪内部还在为是叫新娘还是浪娘而争论不休!……不管你们是企鹅的额娘,豆瓣的伴娘,还是华为的伪娘,都要记得,淘宝才是你们的亲娘啊!亲!!
回复

使用道具 举报

103

主题

1

听众

7956

积分

高级设计师

Rank: 6Rank: 6

纳金币
7953
精华
0

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

6#
发表于 2012-3-9 20:09:50 |只看该作者
回复

使用道具 举报

462

主题

1

听众

31万

积分

首席设计师

Rank: 8Rank: 8

纳金币
2
精华
0

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

7#
发表于 2012-4-3 23:32:31 |只看该作者
百度的叫度娘,网易的叫易娘,新浪内部还在为是叫新娘还是浪娘而争论不休!……不管你们是企鹅的额娘,豆瓣的伴娘,还是华为的伪娘,都要记得,淘宝才是你们的亲娘啊!亲!!
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

8#
发表于 2012-4-30 23:19:13 |只看该作者
不错 非常经典  实用
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

9#
发表于 2012-7-25 23:20:16 |只看该作者
先垫一块,再说鸟
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

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

10#
发表于 2012-9-27 23:23:06 |只看该作者
呵呵,很好,方便罗。
回复

使用道具 举报

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

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-7-14 16:55 , Processed in 0.068184 second(s), 28 queries .

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

© 2008-2019 Narkii Inc.

回顶部