Zt:unity3d Research Institute Use the animation editor edit animation (54)

Source: Internet
Author: User

Original address: Http://www.xuanyusong.com/archives/2246#comments

Original Song Momo April 16, 2013 Yu Yussong Momo Program Research Institute published

Unity provides the animation editor, which can edit physical animations for us. For example, there is a swing swinging back and forth in the scene, and this swing is only a foil to the project, and it does not interact with other game objects. If the swing is also written in code to control it shaking back and forth, it will feel a fuss. You can do this at this time using the animation editor. However, it is not currently possible to edit FK and Ik animations, so the type of editing animation in the editor is still limited, and if one day the FK and Ik animations can be edited in unity then the Ho ho ... As shown, first create a game object in the hierarchy view, where I create a cube cube object. The mouse remains selected, and then in the Unity navigation menu bar, select Window->animation to exhale the animated edit window.

As shown, after the animation window pops up, click on the "Little Red dots" button in the upper left corner. Because the default new cube object is not animated, the Create Animation window will pop up here. Click Save in the window, and an animated file called New animation will be saved in Project view.

As shown, at this time the animation will be in the editing mode, in the upper right margin click the right mouse button, you can add a frame, click on the frame will appear a vertical red line, which corresponds to the frame of the time, in the left transform can modify the position of each frame model, Or it can be modified in the editor, and the values are also saved in the transform of each frame.

when your frame editing is complete, click the button that runs in the upper-left corner. You can see in the game view that this cube object has been playing the animation at the position of each frame we set. The lower left corner of the figure Show:all the right side of the animation to set the playback type. To see clearly, here I choose ping pong to let the animation play back and forth.  When the animation is finished, click the "Little Red dots" button in the upper left corner of the graph to exit the animation editing mode.

After exiting the animation editing mode, drag the animated clip you just edited into the animation of the cube object as shown, and tick play automatically autoplay. When you run the game you will notice that the cube object has been animated in the way it was previously edited.

I did not write any line of code as described above, if you want to listen to some playback events dynamically, such as executing a few lines of code when playing a few seconds. At this point you can use the animated event to complete. Create a generic script first. Bind it to the cube object. In the script I wrote two methods Event0 () and Event1 ().

C #
123456789101112131415 using unityengine; using System. Collections; public class newbehaviourscript : monobehaviour { void Event0() { Debug. Log("Event0"); } void Event1() { Debug. Log("Event1"); }}

We continue to exhale the animation edit window, as shown in the blank space of the timeline, to add an animated event to the right mouse button. The Edit Animation Event window will then pop up with a function option in the middle, and Event0 () will correspond to the Event0 method in the code above. You can also continue to add methods in the script, which you'll see in the function: drop-down menu. In the figure I added an animated event at 0:10, corresponding to the Event0 method, then the program will go into the Event0 method when the animation plays 0.10s.

How about that? Animated events are better understood. Do you want to ask me about this? Can you make the art of animation in unity to complete. The answer is no, because it does not support FK and IK animations, and skeletal animations still have to be done in 3DMAX or Maya. As shown, you can also open an art animation in 3DMAX or Maya, which shows that read-only is read-only and you cannot continue to modify it.

The animation editor can only modify the animation of the current node if you want to edit its child node animations. Just find a child node object in the parent node now and then call out the editor window in window->animation to start editing.

Zt:unity3d Research Institute Use the animation editor edit animation (54)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.