{"id":1,"date":"2025-11-06T16:15:53","date_gmt":"2025-11-06T08:15:53","guid":{"rendered":"http:\/\/12333456.xyz\/?p=1"},"modified":"2025-11-06T16:31:52","modified_gmt":"2025-11-06T08:31:52","slug":"hello-world","status":"publish","type":"post","link":"http:\/\/12333456.xyz\/index.php\/2025\/11\/06\/hello-world\/","title":{"rendered":"\u3010\u4ee3\u7801\u7247\u6bb5\u3011unity\u4eba\u7269\u524d\u540e\u5de6\u53f3\u8d70\u8def+\u52a8\u753b\u4e16\u754c\uff0c\u60a8\u597d\uff01"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic class CharacterController : MonoBehaviour\n{\nprivate CharacterController _character; \/\/ \u660e\u786e\u6307\u5b9a\u547d\u540d\u7a7a\u95f4\nprivate Animator _animator; \/\/\u6dfb\u52a0\n\n\nvoid Start()\n{\n    _animator = GetComponent&lt;Animator>();  \/\/\u7ed1\u5b9a\u89d2\u8272\u63a7\u5236\u5668\n    _character = GetComponent&lt;CharacterController>(); \/\/ \u4fee\u6b63\u5927\u5c0f\u5199\n}\n\nvoid Update()\n{\n    float horizontal = Input.GetAxis(\"Horizontal\");  \/\/\u83b7\u53d6\u4eba\u7269\u6a2a\u5411\n    float vertical = Input.GetAxis(\"Vertical\");      \/\/\u83b7\u53d6\u4eba\u7269\u7eb5\u5411\n\n    Vector3 dir = new Vector3(horizontal, 0, vertical); \/\/ \u6dfb\u52a0\u5206\u53f7\n    if (dir != Vector3.zero)  \/\/\u5728Unity\u8bbe\u7f6e\u597d\u89d2\u8272\u63a7\u5236\u5668\u540e\u5728\u8fd9\u91cc\u5224\u65ad\u52a8\u753b\n    {\n        transform.rotation = Quaternion.LookRotation(dir); \/\/ \u4fee\u6b63\u62fc\u5199\n\n        _animator.SetBool(\"isRun\",true);  \/\/\u4eba\u7269\u8dd1\u6b65\u52a8\u753b\n\n        transform.Translate(Vector3.forward * 2 * Time.deltaTime); \/\/ \u8d70\u8def\u901f\u5ea6\n    }else\n    {\n        _animator.SetBool(\"isRun\", false);  \/\/\u4eba\u7269\u5f85\u673a\u52a8\u753b\n    }\n\n}<\/code><\/pre>\n\n\n\n<p>}<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>}<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":2,"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":12,"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/posts\/1\/revisions\/12"}],"wp:attachment":[{"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/12333456.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}