纳金网

标题: unity3d动作事件运用(一) [打印本页]

作者: 会飞的鱼    时间: 2011-11-14 15:22
标题: unity3d动作事件运用(一)


           不错的英文教程,有源文件供下载,主要讲解unity3d动画事件的运用!
           

           I recently changed jobs a couple of months ago and have been pretty busy trying to get up to speed with it. I have been neglecting this blog for a while, which is something that I don’t like.
         

           For the Witch Training game I have been working on, the biggest thing that I am proud of myself right now is getting all of the controls about 90% done along with getting in the animation events to fire off walking***nning sounds.
         

           I wrote a post a little while ago on animation events describing what they are and how to do them in code. In the original article, I said how to just do it all in code because I don’t like the copying method. I firmly retract my statement and think that doing the copy method is the best way for looped animations. I did have to do some trickery to get it to work right though.
         

           If you can’t here it, there is sound effects for every footstep whether the witch is walking or***nning. The way I did it is the following.
         

           Animation States
           

           To create animation events for locked animations, the best way to add events is to duplicate the animation state. What does that mean? It means that you need to select the animation in your project window and go to Edit > Copy . See image below.
         

            
           








           Copying the animation from model
         

           The above image is the type of thing you want to copy. If you aren’t using the model in my project, Ramius is the character’s model I made in Blender3D. Unity will create all of these items based on your import settings. The animations were created in the import settings as well with the names you give them. Select the animation like above copy and paste it.
         

           The reason why you have to copy it is because the original walk animation is really just a dynamically created setting that Unity creates from the source file. You can’t edit or save it because it will constantly rebuild itself everytime you load new files or update anything. The only way to do anything with these files is duplicate them so there is a static version. You can do things like animation events at that point.
         

            
           






           Animation state copies sitting safely outside of the model
         

           Once you have the copy, you can add it to your animation state on your game object  in your animation component. Once you’ve added a animation component to your gameobject you want to animate, select the object you have your animation component on and add the new references to it. See below.
         




            
         

           I added the new***n and walk animations to the “Elements”. I do that by usually selecting one of the small “0&rime; on the right side of the image. You can select your duplicated animation state. With the game object still selected go to Window > Animation in the top toolbar to start setting points.
           








           Selecting animation state to add animation event
         

           You will see that when you choose which animation you want to edit, most of them will say “Read-Only”. This is because these animations are getting pulled from Blender,the 3d program I am using, to get this animation data. You can’t edit or add and save animation events with these.
         

           But that doesn’t matter since we already created a copy of what we want to use. You can see by the picture above that the***n and walk animations don’t have “Read-only”, since we duplicated them.
         

           Side Note: You must have your gameobject in the heirarchy selected to see your new animations with your object. If you select your 3d model in the project panel, your new animations won’t appear. This is because they aren’t linked to your model. That is what you were doing when you added them to the animation  component.
           

            
         

作者: 晃晃    时间: 2012-5-9 23:22
不错哦,谢谢楼主

作者: tc    时间: 2012-8-15 23:44
既来之,则看之!

作者: tc    时间: 2012-8-18 23:46
楼主收集的可真全哦

作者: 菜刀吻电线    时间: 2012-8-24 00:09
你们都躲开,我来顶

作者: nts    时间: 2013-10-17 10:46
强大的文章,慢慢学习
作者: Icestar    时间: 2013-10-17 11:46
谢谢楼主




欢迎光临 纳金网 (http://rs.narkii.com/club/) Powered by Discuz! X2.5