{"id":1659,"date":"2022-06-01T13:40:47","date_gmt":"2022-06-01T05:40:47","guid":{"rendered":"https:\/\/104.es\/?p=1659"},"modified":"2022-06-01T13:40:47","modified_gmt":"2022-06-01T05:40:47","slug":"unity-keyboard-input","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2022\/06\/01\/unity-keyboard-input\/","title":{"rendered":"\u5728Unity\u4e2d\u5075\u6e2c\u9375\u76e4\u6309\u9375\u4e4b\u7a0b\u5f0f"},"content":{"rendered":"\n<p>\u5efa\u7acb\u4e00\u6bb5C#\u7a0b\u5f0f\u78bc\uff0c\u628a\u8a72\u7a0b\u5f0f\u78bc\u4f5c\u70ba\u60f3\u8981\u63a7\u5236\u7684\u7269\u9ad4\u4e4b\u5143\u4ef6\uff0c\u7136\u5f8c\u4fee\u6539Update()\u4e2d\u7684\u7a0b\u5f0f\u78bc\u5982\u4e0b\u5373\u53ef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    public fload RotationRate = 20f;\n    void Update()\n    {\n        transform.Rotate(Vector3.forward, RotationRate * Time.deltaTime);\n        if (Input.GetKey(KeyCode.LeftArrow))\n        {\n            \/\/Vector3 position = this.transform.position;\n            \/\/position.x--;\n            \/\/this.transform.position = position;\n            transform.Translate(Vector3.left * Time.deltaTime);\n        }\n        if (Input.GetKey(KeyCode.RightArrow))\n        {\n            \/\/Vector3 position = this.transform.position;\n            \/\/position.x++;\n            \/\/this.transform.position = position;\n            transform.Translate(Vector3.right * Time.deltaTime);\n        }\n    }\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u8ff0\u7684\u7a0b\u5f0f\u9664\u4e86\u53ef\u4ee5\u4f9d\u7167\u4f7f\u7528\u8005\u7684\u65b9\u5411\u9375\u4f86\u9032\u884c\u7269\u9ad4\u7684\u79fb\u52d5\u4e4b\u5916\uff0c\u4e5f\u5177\u5099\u81ea\u884c\u65cb\u8f49\u7684\u80fd\u529b\u3002\u81f3\u65bcVector3.right\u4ee5\u53ca\u76f8\u95dc\u8b8a\u6578\u6240\u4ee3\u8868\u7684\u610f\u7fa9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>forward =&gt; (0, 0, 1)\nback =&gt; (0, 0 =1)\nup =&gt; (0, 1, 0)\ndown =&gt; (0, -1, 0)\nright =&gt; (1, 0, 0)\nleft =&gt; (-1, 0, 0)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Unity\u4e2d\u5075\u6e2c\u6309\u9375\u5167\u5bb9\u7136\u5f8c\u79fb\u52d5\u7269\u9ad4\u7684\u7a0b\u5f0f\u78bc\uff0c\u4e3b\u8981\u5c31\u662f\u5229\u7528Input.Get()\u51fd\u5f0f\uff0c\u8acb\u53c3\u8003\u672c\u7bc7\u6587\u7ae0\u4e2d\u7684\u8aaa\u660e\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[18],"tags":[],"class_list":["post-1659","post","type-post","status-publish","format-standard","hentry","category-unity"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/comments?post=1659"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1659\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=1659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=1659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=1659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}