{"id":1108,"date":"2011-12-07T23:25:11","date_gmt":"2011-12-07T23:25:11","guid":{"rendered":"http:\/\/www.west-racing.com\/mf\/?page_id=1108"},"modified":"2013-09-27T10:53:15","modified_gmt":"2013-09-27T10:53:15","slug":"morph-animator","status":"publish","type":"page","link":"http:\/\/www.west-racing.com\/mf\/?page_id=1108","title":{"rendered":"Morph Animator"},"content":{"rendered":"<p>This a clip based animation system for the Morph component which allows you to add any number of anim clips which can be selected and played back using the C# methods for the class as shown below. You just need to click the Add Clip button and add as many slots as you need and then fill in the start and end times and loop mode. This component is aimed at scripters who want to have direct control over the animations of the morphing system. Note the clip start and end values are in seconds not frames.<br \/>\n<div class=\"message_box info_box\">\n<p class=\"message_box_sign info_box_sign\">Info<\/p>\nMake sure you uncheck the Animate box in the morph component else the Morph Animator clips will not play.\n<\/div><br \/>\n<a href=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/12\/moranimator1.jpg\"><img loading=\"lazy\" src=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/12\/moranimator1.jpg\" alt=\"\" title=\"Morph Animator\" width=\"244\" height=\"241\" class=\"alignright size-full wp-image-3696 fancy\" \/><\/a><\/p>\n<h3>Mega Animator Param Description<\/h3>\n<h4><strong>Use Frames<\/strong><\/h4>\n<p>You can choose to define your animation clips in either frames or by time. If you choose frames then the Source FPS value will be used to calculate the timing. So if your 3d package has exported your animation at 24fps then you should enter 24 in the Source FPS box, the default is 30.<\/p>\n<h4><strong>Source FPS<\/strong><\/h4>\n<p>The frames per second count that the animation was built at in your 3d package.<\/p>\n<h4><strong>Multiple Morphs<\/strong><\/h4>\n<p>If you have a character that is made up of multiple morphs and you would like to control all those morphs at the same time using the same clips then you can check this box, the system will then find and update any morph component in the children of this object.<\/p>\n<h4><strong>Linked Update<\/strong><\/h4>\n<p>If your main character has a load of animations already loaded into the main Unity animation system you can select this option to have the system try and match the morph animation to whatever main animation is running on your character, to make this happen you must name the clips below to match the names of the Unity animation clips, then the system will watch the main object for changes to the main Unity animation clip and will look to see if there is a morph anim clip with the same name, if it finds one it will start that playing.<\/p>\n<h4><strong>Play On Start<\/strong><\/h4>\n<p>If this is checked then the Playing Clip will be started when the game is run.<\/p>\n<h4><strong>Playing Clip<\/strong><\/h4>\n<p>Click this to select the clip you want to be playing. A box will open showing all the clips on this morph to select from.<\/p>\n<h4><strong>Add Clip<\/strong><\/h4>\n<p>Click this to append a new clip slot to the bottom of the list. You can then fill in the start and end times and loop mode.<\/p>\n<h4><strong>Clip Line<\/strong><\/h4>\n<p>Each clip has a slot here which shows the name of the clip the start and end time or frame number and the anim loop mode, all these values can be edited. The last button is a delete channel button.<\/p>\n<p>You can also control the the play back of clips via the Unity Animation Event system, you just add an event to a Unity Animation clip at the time you need then select &#8216;PlayClip(int clip)&#8217; from the function selection box and provide the index of the clip you want to start playing at that time. You can find more information on Unity Animation Events <a href=\"http:\/\/docs.unity3d.com\/Documentation\/Components\/animeditor-AnimationEvents.html\">Here<\/a><\/p>\n<p>The other option is to control the animation from script by calling one of the methods listed below.<\/p>\n<h3>C# Functions<\/h3>\n<p>This system exposes a set of methods so the morph system can be controlled by clips and code.<\/p>\n<div class=\"method\">\n<h4>bool IsPlaying()<\/h4>\n<p>Returns true is an animation is currently being played.\n<\/p><\/div>\n<div class=\"method\">\n<h4>void SetTime(float time)<\/h4>\n<p>Allows you to set the time manually if you want to override the animation system.<\/p>\n<p>Parameters<br \/>\ntime &#8211; Time to set.\n<\/p><\/div>\n<div class=\"method\">\n<h4>float GetTime()<\/h4>\n<p>Returns the current time of the animation system.\n<\/p><\/div>\n<div class=\"method\">\n<h4>void PlayClip(int clip)<\/h4>\n<p>Starts a new animation by index.<\/p>\n<p>Parameters<br \/>\nclip &#8211; The new clip to start playing.\n<\/p><\/div>\n<div class=\"method\">\n<h4>void PlayClip(string name)<\/h4>\n<p>Starts a new animation by name, will look through the clip array for a match, if none is found nothing happens.<\/p>\n<p>Parameters<br \/>\nname &#8211; Animation clip to start playing.\n<\/p><\/div>\n<div class=\"method\">\n<h4>void Stop()<\/h4>\n<p>Stops any animation playing\/\n<\/p><\/div>\n<div class=\"method\">\n<h4>int AddClip(string name, float start, float end, MegaRepeatMode loop)<\/h4>\n<p>Allows you to easily add a new script via code. Returns the index of the newly created clip.<\/p>\n<p>Parameters<br \/>\nname &#8211; Name for the new clip.<br \/>\nstart &#8211; Start time for the clip.<br \/>\nend &#8211; End time for the clip.<br \/>\nloop &#8211; Looping mode for the animation, either Loop, Clamp or PingPong.\n<\/p><\/div>\n<div class=\"method\">\n<h4>string[] GetClipNames()<\/h4>\n<p>Returns a string array of all the animation clip names.\n<\/p><\/div>\n<h3>Animator Classes<\/h3>\n<p>[cc lang=&#8221;c#&#8221;]public class MegaMorphAnimClip<br \/>\n{<br \/>\n\tpublic string\t\t\tname;<br \/>\n\tpublic float\t\t\tstart;<br \/>\n\tpublic float\t\t\tend;<br \/>\n\tpublic MegaRepeatMode\tloop;<br \/>\n}<\/p>\n<p>public class MegaMorphAnimator : MonoBehaviour<br \/>\n{<br \/>\n\tpublic MegaMorph                morph;<br \/>\n    public MegaMorphBase[]        \tmorphs;<br \/>\n\tpublic List<MegaMorphAnimClip>  clips;<br \/>\n\tpublic int                      current;<br \/>\n\tpublic float                    t;<br \/>\n\tpublic float                    at;<br \/>\n    public int                      sourceFPS;<br \/>\n\tpublic bool\t                    useFrames;<br \/>\n}[\/cc]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This a clip based animation system for the Morph component which allows you to add any number of anim clips which can be selected and played back using the C# [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":257,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/1108"}],"collection":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1108"}],"version-history":[{"count":19,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/1108\/revisions"}],"predecessor-version":[{"id":4389,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/1108\/revisions\/4389"}],"up":[{"embeddable":true,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/257"}],"wp:attachment":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}