{"id":2645,"date":"2012-08-02T11:31:12","date_gmt":"2012-08-02T11:31:12","guid":{"rendered":"http:\/\/www.west-racing.com\/mf\/?page_id=2645"},"modified":"2012-08-02T13:24:41","modified_gmt":"2012-08-02T13:24:41","slug":"megaattach","status":"publish","type":"page","link":"http:\/\/www.west-racing.com\/mf\/?page_id=2645","title":{"rendered":"Mega Attach"},"content":{"rendered":"<p>Quite often you may want to attach an object to a deforming mesh, such as an item of clothing, a weapon, or parts of a vehicle, this is usually done via making the object a child of the object you wish to attach it to, but if the mesh deforms a lot then the object may not be positioned correctly relative to the deforming surface, this is where the MegaAttach helper script comes in.<\/p>\n<p>Using MegaAttach to are actually attaching the object to a point on the mesh surface so no matter how the mesh deforms the object will always be positioned and orientated correctly. This system also works for animated skinned objects making it even more useful.<\/p>\n<p>To use attach the MegaAttach component to the object you want to position and then select the target mesh which will be a deforming mesh. You will then see a red dot appear on the mesh which shows the current attachment point, as you move your object around the system will attempt to find the nearest point on the target mesh. When you are happy with the attachment point you can set the blue point using the Attach Fwd values, this just serves as a reference point that is used to calculate the orientation of the attached object. When you are happy click the Attach button and the red dot will go green showing the object is attached.<\/p>\n<h3>MegaAttach Params<\/h3>\n<p><a href=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2012\/08\/attach.jpg\"><img loading=\"lazy\" src=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2012\/08\/attach.jpg\" alt=\"\" title=\"Mega Attach\" width=\"260\" height=\"214\" class=\"alignright size-full wp-image-2649 fancy\" \/><\/a><\/p>\n<h4><strong>Target<\/strong><\/h4>\n<p>The deforming mesh you want to attach to.<\/p>\n<h4><strong>Attach Fwd<\/strong><\/h4>\n<p>Value used to position the forward vector, it is not too important where this is just needs to be different from the attach point.<\/p>\n<h4><strong>Axis Rot<\/strong><\/h4>\n<p>You can apply a rotation to the attached object by changing this.<\/p>\n<h4><strong>Radius<\/strong><\/h4>\n<p>Radius of the attachment gizmos.<\/p>\n<h4><strong>Up<\/strong><\/h4>\n<p>If your orientations are wrong after attaching you can change the up vector value used by the system.<\/p>\n<h4><strong>World Space<\/strong><\/h4>\n<p>Check this to have the calculated values stored in the world space values of the transform. If unchecked the values will be calculated for the local space of the object.<\/p>\n<h4><strong>Attach\/Detach<\/strong><\/h4>\n<p>Click the Attach button to attach the object, the button will then change to Detach which you can click to detach the object.<\/p>\n<h3>MegaAttach Class<\/h3>\n<p>[cc lang=&#8221;c#&#8221;]public class MegaAttach : MonoBehaviour<br \/>\n{<br \/>\n\tpublic MegaModifiers\ttarget;<br \/>\n\tpublic Vector3\t\t\tattachforward;<br \/>\n\tpublic Vector3\t\t\tAxisRot;<br \/>\n\tpublic float\t\t\tradius;<br \/>\n\tpublic Vector3\t\t\tup;<br \/>\n\tpublic bool\t\t\t\tworldSpace;<br \/>\n\tpublic bool\t\t\t\tskinned;<br \/>\n}[\/cc]<\/p>\n<h3>MegaAttach Tutorial<\/h3>\n<p>A little video guide to using the MegaAttach system.<br \/>\n<a href=\"http:\/\/www.youtube.com\/watch?v=6aOz8rmv22s&#038;hd=1&#038;fs=1&#038;autoplay=1\" class=\"fancybox-youtube\"><img loading=\"lazy\" src=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2012\/04\/tut1.jpg\" alt=\"\" title=\"Mega Attach Click to Play\" width=\"680\" height=\"406\" class=\"aligncenter size-full wp-image-1911 fancy\" srcset=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2012\/04\/tut1.jpg 680w, http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2012\/04\/tut1-300x179.jpg 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<h3>MegaAttach on a Skinned Mesh<\/h3>\n<p><a href=\"http:\/\/www.youtube.com\/watch?v=XKhmoAMwGB0&#038;hd=1&#038;fs=1&#038;autoplay=1\" class=\"fancybox-youtube\"><img loading=\"lazy\" src=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2012\/07\/ytskinattach.jpg\" alt=\"\" title=\"Skin Attach Click to Play\" width=\"680\" height=\"405\" class=\"aligncenter size-full wp-image-2451 fancy\" srcset=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2012\/07\/ytskinattach.jpg 680w, http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2012\/07\/ytskinattach-300x178.jpg 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quite often you may want to attach an object to a deforming mesh, such as an item of clothing, a weapon, or parts of a vehicle, this is usually done [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":38,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/2645"}],"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=2645"}],"version-history":[{"count":12,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/2645\/revisions"}],"predecessor-version":[{"id":2660,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/2645\/revisions\/2660"}],"up":[{"embeddable":true,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/38"}],"wp:attachment":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}