{"id":151,"date":"2023-04-21T18:44:16","date_gmt":"2023-04-22T02:44:16","guid":{"rendered":"https:\/\/karasu.tech\/?p=151"},"modified":"2024-09-21T06:13:56","modified_gmt":"2024-09-21T14:13:56","slug":"unity%e5%8a%a8%e7%94%bb%e3%80%81%e7%8a%b6%e6%80%81%e6%9c%ba%e3%80%81%e6%9d%83%e8%a1%a1%e5%88%a9%e5%bc%8a","status":"publish","type":"post","link":"https:\/\/karasu.tech\/?p=151","title":{"rendered":"Unity\u52a8\u753b\u3001\u72b6\u6001\u673a\u3001\u6743\u8861\u5229\u5f0a"},"content":{"rendered":"<blockquote><p>\n  \u6e38\u620f\u5728unity\u4e2d\u7684\u8d44\u4ea7\u62c6\u89e3\uff1a<br \/>\n  1. unity\u6e38\u620f\u662f\u7531\u573a\u666f\u7ec4\u6210<br \/>\n  2. \u573a\u666f\u7531\u6e38\u620f\u5bf9\u8c61\u7ec4\u6210<br \/>\n  3. \u6e38\u620f\u5bf9\u8c61\u7531\u7ec4\u4ef6\u7ec4\u6210\n<\/p><\/blockquote>\n<p><strong>\u7ec4\u4ef6\u51b3\u5b9a\u4e86\u6e38\u620f\u5bf9\u8c61\u7684\u529f\u80fdunity\u63d0\u4f9b\u4e86\u57fa\u7840\u7ec4\u4ef6\uff1a<\/strong><\/p>\n<ul>\n<li>transform-\u4f4d\u59ff\u7ec4\u4ef6<\/li>\n<li>light-\u5149\u6e90\u7ec4\u4ef6<\/li>\n<li>camrea-\u76f8\u673a\u7ec4\u4ef6<\/li>\n<li>animator-\u52a8\u753b\u7ec4\u4ef6<\/li>\n<li>box collider-\u89e6\u53d1\u5668\u7ec4\u4ef6<\/li>\n<li>sprite renderer-\u56fe\u7247\u7ed8\u5236\u7ec4\u4ef6<\/li>\n<li>navigation agent-\u5bfc\u822a\u7ec4\u4ef6<\/li>\n<li>character control-\u89d2\u8272\u63a7\u5236\u7ec4\u4ef6<\/li>\n<li>\u5b9a\u5236\u5316\u7ec4\u4ef6-mono behavior\u7ec4\u4ef6\uff08\u811a\u672c\u7ec4\u4ef6\uff09<\/li>\n<\/ul>\n<p>\u7b49\u7b49\u7b49\u7b49\u7ec4\u4ef6    \u3002\u3002\u3002\u3002\u3002<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<blockquote><p>\n  \u4eba\u7269\u52a8\u753b\u9aa8\u9abc\u767d\u5ad6\u5de5\u5177mixamo\uff1ahttps:\/\/www.mixamo.com\/unity\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n<strong>unity\u52a8\u753b\u7cfb\u7edf\u5206\u4e3a\u4e09\u4e2a\u90e8\u5206\uff1a<\/strong><br \/>\n&#8211; \u52a8\u753b\u7247\u6bb5 animation clip-\u5bf9\u7269\u4f53\u53d8\u5316\u5f62\u6001\u7684\u4e00\u79cd\u5c55\u793a<br \/>\n&#8211; \u52a8\u753b\u72b6\u6001\u673a animator Controller-\u5e2e\u52a9\u6211\u4eec\u8ddf\u8e2a\u5f53\u524d\u52a8\u753b\u7684\u64ad\u653e\u72b6\u6001\uff0c\u6839\u636e\u8bbe\u7f6e\u51b3\u5b9a\u4f55\u65f6\u5207\u6362\u52a8\u753b\u7247\u6bb5<br \/>\n&#8211; \u52a8\u753b\u7ec4\u4ef6 animator Component-\u7ba1\u7406\u63a7\u5236\u52a8\u753b\u72b6\u6001\u673a\u4e0e\u66ff\u8eab\uff0c\u63d0\u4f9b\u811a\u672c\u8bbf\u95ee\u52a8\u753b\u7ec4\u4ef6\u7684\u80fd\u529b<br \/>\n&#8211; \u66ff\u8eab Avatar\uff08\u4eba\u5f62\u52a8\u753b\uff09-\u4eba\u5f62\u52a8\u753b\u7684\u9aa8\u9abc\u6807\u51c6<\/p>\n<p>\u52a8\u753b\u7247\u6bb5\u672c\u8eab\u662f\u4ee5YMAL\u8bed\u8a00\u7f16\u5199\uff0c\u52a8\u753b\u6587\u4ef6\u5b9e\u9645\u662f\u4e00\u4e2a\u63cf\u8ff0\u7269\u4f53\u53d8\u5316\u7684\u6587\u4ef6\u5728unity\u4e2d\u7684\u5927\u591a\u8d44\u6e90\u6587\u4ef6\u90fd\u662fYMAL\u6587\u4ef6\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\uff1a<br \/>\n&#8211; \u52a8\u753b\u7247\u6bb5<br \/>\n&#8211; \u52a8\u753b\u63a7\u5236\u5668<br \/>\n&#8211; \u9884\u5236\u4ef6\uff08perfab\uff09<br \/>\n&#8211; \u573a\u666f\u6587\u4ef6<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/wp_editor_md_040266e2b22e31a94cb27a292a07f31f.jpg\"><img decoding=\"async\" src=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/wp_editor_md_040266e2b22e31a94cb27a292a07f31f.jpg\" alt=\"\" \/><\/a><\/p>\n<p>&nbsp;<br \/>\n&nbsp;<br \/>\n<strong>\u52a8\u753b\u590d\u7528<\/strong><br \/>\n\u5f53\u52a8\u753b\u5bf9\u591a\u4e2a\u6e38\u620f\u7269\u4f53\/\u5bf9\u8c61\u65f6\uff0c\u4f1a\u5728YMAL\u6587\u4ef6\u4e2d\u8bf4\u660e\u52a8\u753b\u751f\u6548\u7684\u5bf9\u8c61\u540d\u79f0\uff08\u5f53\u6e38\u620f\u5bf9\u8c61\u7684\u540d\u5b57\u4e0e\u6587\u4ef6\u4e2d\u4e0d\u4e00\u81f4\uff0cunity\u5219\u65e0\u6cd5\u6b63\u5e38\u64ad\u653e\uff09<br \/>\n\u56e0\u6b64\u9762\u5bf9\u590d\u6742\u7684\u4eba\u4f53\u52a8\u753b\u5219\u4f1a\u4f7f\u7528avatar\u7cfb\u7edf\uff08\u5373\u4e3a\u9aa8\u9abc\u6620\u5c04\uff09<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/wp_editor_md_5ff7af4de9f0f418a79026f8ce75040f.jpg\"><img decoding=\"async\" src=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/wp_editor_md_5ff7af4de9f0f418a79026f8ce75040f.jpg\" alt=\"\" \/><\/a><\/p>\n<p><strong>unity\u5185\u73b0\u5b58\u7684\u51e0\u7c7b\u52a8\u753b\u7c7b\u578b\uff1a<\/strong><br \/>\n1. None-\u4e0d\u4f1a\u6709\u72ec\u7acb\u7684\u52a8\u753b\u7247\u6bb5\u6e38\u620f\u5bf9\u8c61<br \/>\n2. Legacy-unity\u5386\u53f2\u9057\u7559\u7684\u52a8\u753b\u6587\u4ef6\uff08\u6682\u4e0d\u8003\u8651\uff09<br \/>\n3. Generic &#8211; \u666e\u901a\u52a8\u753b\uff0c\u9762\u5411\u98de\u79bd\u8d70\u517d\u7c7b\u7b49\u7269\u4f53\u6e38\u620f\u5bf9\u8c61<br \/>\n4. Humanoid &#8211; \u4eba\u5f62\u52a8\u753b<\/p>\n<p>AVATAR\u5219\u662funity\u5185\u5b9a\u4e49\u7684\u808c\u8089\u7fa4\u52a8\u753b<\/p>\n<hr \/>\n<p><strong>Animator\u7ec4\u4ef6<\/strong><br \/>\n<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/wp_editor_md_f149b0b80dce3262470e227596a92fef.jpg\"><img decoding=\"async\" src=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/wp_editor_md_f149b0b80dce3262470e227596a92fef.jpg\" alt=\"\" \/><\/a><\/p>\n<p>apply root motion\u5c5e\u6027\u662f\u5426\u5c06\u52a8\u753b\u7684\u4f4d\u79fb\u5b9e\u9645\u751f\u6548\uff08\u5373\u52a8\u753b\u6587\u4ef6\u4e2d\u7684\u4f4d\u79fb\u6548\u679c\u5e94\u7528\u81f3\u573a\u666f\u4e2d\uff09<\/p>\n<p><strong>updata mode\u5219\u662f\u52a8\u753b\u7684\u5237\u65b0\u6a21\u5f0f<\/strong><br \/>\n* normal\u4e0e updata{} \u540c\u6b65\uff0c\u4e0e\u5e27\u6570\u540c\u6b65<br \/>\n* animate physics \u4e0e\u7269\u7406\u5f15\u64ce\u540c\u6b65\uff0c\u6bcf\u6b21\u8fdb\u884c\u78b0\u649e\u5219\u8ba1\u7b97\u52a8\u753b\u65b9\u5f0f\uff08\u4f8b\u5982\u52a8\u4f5c\u6e38\u620f\uff0c\u4ea4\u4e92\u6027\u8f83\u5f3a\uff09<\/p>\n<p>CullingMode\uff08\u5254\u9664\u6a21\u5f0f\uff09\uff0c\u662f\u56fe\u5f62\u5b66\u7684\u4e00\u4e2a\u6982\u5ff5\uff0c\u53ea\u5f53\u6ca1\u6709\u88ab\u6444\u50cf\u673a\u770b\u5230\u65f6\u662f\u5426\u7ee7\u7eed\u6267\u884c\u52a8\u753b<\/p>\n<blockquote><p>\n  <strong>Root motion \u4e0e rigibody\u7684\u6743\u8861\u5229\u5f0a<\/strong><br \/>\n  root motion\u8bbe\u8ba1\u521d\u8877\uff0c\u662f\u5c06\u52a8\u753b\u8868\u73b0\u4e0e\u5b9e\u9645\u7269\u7406\u53d8\u5316\u505a\u9002\u914d<br \/>\n  rigibody\u5219\u662f\u771f\u5b9e\u7269\u7406\u78b0\u649e<br \/>\n  \u82e5\u5c06\u52a8\u753bclip\u4e2d\u7684\u53d8\u5316\u6570\u636e\u5e94\u7528\u81f3rigibody\u9a71\u52a8\u7684\u6e38\u620f\u5bf9\u8c61\u65f6\uff0c\u9700\u8981\u6743\u8861\u5229\u5f0a\n<\/p><\/blockquote>\n<hr \/>\n<p>&nbsp;<br \/>\n<strong>animator control\u662funity\u7684\u4e00\u79cd\u56fe\u5f62\u5316\u52a8\u753b\u72b6\u6001\u7ba1\u7406\u4ea4\u4e92\u754c\u9762\uff0c\u662f\u63a7\u5236\u591a\u4e2a\u52a8\u753b\u6587\u4ef6\u64ad\u653e\u548c\u5207\u6362\u7684\u5de5\u5177<\/strong><br \/>\n<strong>animator control\u540c\u6837\u662fYAML\u6587\u4ef6<\/strong><\/p>\n<p>\u5728unity\u4e2d\u52a8\u753b\u72b6\u6001\u5206\u4e3a\u4e09\u79cd\uff1a<br \/>\n* \u72ec\u7acb\u7684\u52a8\u753b\u7247\u6bb5<br \/>\n* \u591a\u4e2a\u52a8\u753b\u7247\u6bb5\u7ec4\u6210\u7684blend tree<br \/>\n* \u5d4c\u5957\u7684\u53e6\u4e00\u4e2a\u52a8\u753b\u72b6\u6001\u673a<\/p>\n<blockquote><p>\n  \u5c0ftips\uff1a\u5728\u590d\u6742\u7684\u72b6\u6001\u673a\u4e2d\u53ef\u4ee5\u4f7f\u7528auto live link\u53bb\u5b9a\u4f4d\u5f53\u524d\u64ad\u653e\u7684\u52a8\u753b\n<\/p><\/blockquote>\n<hr \/>\n<p><strong>\u52a8\u753b\u72b6\u6001\uff08AinamtorStateInfo\uff09\u5206\u4e3a\uff1a<\/strong><br \/>\n1. name<br \/>\n2. tag\u00a0<br \/>\n3. Motion\uff0c\u7ba1\u7406\u7684\u52a8\u753bclip\u6216\u8005blend treespeed\uff0c\u76f8\u8f83\u4e3a\u52a8\u753bclip\u7684\u64ad\u653e\u500d\u901f\uff0c\u4e0d\u53ef\u5728\u811a\u672c\u5185\u63a7\u5236<br \/>\n4. Multiper\uff0c\u64ad\u653e\u500d\u901f\u53d8\u91cf\uff0c\u53ef\u7531\u811a\u672c\u63a7\u5236\uff08\u9700\u5173\u8054\u6d6e\u70b9\u53d8\u91cf\uff09<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p>\n  \u5728\u811a\u672c\u4e2d\u8c03\u7528\u52a8\u753b\u53d8\u91cf\u65f6\uff0c\u53ef\u7528hash\u7f6e\u505a\u5339\u914d\uff0cunity\u5185\u7f6e\u7684\u4e86hash\u8f6c\u5316\uff0c\u5982\u4e0b\n<\/p><\/blockquote>\n<pre><code class=\"language-C line-numbers\">{\n    int scalerHash\uff1b\/\/\u53d8\u91cf\u503c\n    Animator animator;\n    \u00a0void Start()\n\u00a0\u00a0 {       \n        animator = GetComponent&lt;Animator&gt;();\n        scalerHash = Animator.StringToHash(\"Scaler\");\n        animator.SetFloat(scalarHash, animationScalar);\n\u00a0\u00a0\u00a0 }\n}\n<\/code><\/pre>\n<p>&nbsp;<br \/>\n5. Motion time,\u9009\u7ba1\u7406\u52a8\u753b\u7247\u6bb5\u8fdb\u5ea6\uff08\u4ece0\u21921\uff09\uff0c\u53ef\u7531\u811a\u672c\u63a7\u5236\uff08\u9700\u5173\u8054\u6d6e\u70b9\u53d8\u91cf\uff09<br \/>\n6. Mirror\u955c\u50cf\uff0c\u53ea\u5bf9\u4eba\u5f62\u52a8\u753b\u751f\u6548<br \/>\n7. Cycle offset\uff0c\u64ad\u653e\u5f00\u59cb\u65f6\u8fdb\u884c\u8fdb\u5ea6\u504f\u79fb\uff08\u8c03\u6574\u52a8\u753b\u7684\u8d77\u59cb\u70b9\uff09<\/p>\n<hr \/>\n<p><strong>Foot IK\uff0c\u53cd\u5411\u52a8\u529b\u5b66<\/strong><\/p>\n<blockquote><p>\n  \u7531\u52a8\u6355\u6349\uff0c\u7f8e\u672f\u5236\u4f5c\u4ea7\u751f\u7684\uff0c\u7531\u9aa8\u9abc\u6839\u8282\u70b9\u5c55\u5f00\u7684\uff0c\u5230\u80a2\u4f53\u672b\u68a2\u8282\u70b9\u4f9d\u6b21\u8ba1\u7b97\u5176\u4f4d\u79fb\u3001\u65cb\u8f6c\u548c\u7f29\u653e\uff0c\u6700\u7ec8\u51b3\u5b9a\u6bcf\u4e00\u5757\u9aa8\u9abc\u7684\u4f4d\u7f6e\uff0c\u88ab\u6210\u4e3a\u6b63\u5411\u52a8\u529b\u5b66\u3002<br \/>\n  Foot IK \u5b9e\u9645\u4f7f\u7528\u4e86IK\u7684\u52a8\u753b\u77eb\u6b63\u673a\u5236\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n<strong>Unity\u7684avatar\u7cfb\u7edf\uff0c\u9884\u5148\u8bbe\u7f6e\u4e86\u624b\u811aIK goal\uff0c\u56e0\u6b64\u5e26\u6765\u4e86\u5f88\u591a\u5751<\/strong><\/p>\n<p>Foot IK\u4f1a\u5c06\u52a8\u753b\u4e2d\u624b\u811a\u66f4\u5f80IK goal\u9760\u8fd1\u77eb\u6b63\uff0c\u4f46\u662f\u4e0d\u4e00\u5b9a\u80fd\u6ee1\u8db3\u9ad8\u8d28\u91cf\u7684\u52a8\u753b\u9700\u6c42<br \/>\n\u901a\u8fc7\u4ee3\u7801\u8c03\u6574IK goal\u7684\u4f4d\u7f6e\uff0c\u5e76\u4e0d\u4f1a\u8c03\u6574Foot IK\u77eb\u6b63\u903b\u8f91<\/p>\n<blockquote><p>\n  \u5728\u811a\u672c\u4e2d\u8c03\u7528IK\u9700\u8981\u6fc0\u6d3bIK Pass<br \/>\n  <img decoding=\"async\" src=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/547_1-300x89.png\" alt=\"\" \/>\n<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<hr \/>\n<p><strong>\u5b9a\u65f6\u70b8\u5f39 Write Defaults<\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/551_1-300x13.png\" alt=\"\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/karasu.tech\/wp-content\/uploads\/2024\/09\/549_1-300x33.png\" alt=\"\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd1\u671f\u5bf9unity\u52a8\u753b\u7ec4\u4ef6\u7684\u7247\u9762\u5b66\u4e60\uff0c\u5305\u542bClip\uff0cController\uff0cComponent\uff0cAvatar\u7684\u76f8\u5173\u7b14\u8bb0<\/p>\n","protected":false},"author":2,"featured_media":158,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[12,11],"class_list":["post-151","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-game-engine","tag-unity","tag-11"],"_links":{"self":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=151"}],"version-history":[{"count":5,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":163,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions\/163"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=\/wp\/v2\/media\/158"}],"wp:attachment":[{"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/karasu.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}