{"id":5518,"date":"2017-03-07T10:00:33","date_gmt":"2017-03-07T01:00:33","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=5518"},"modified":"2017-03-06T19:24:49","modified_gmt":"2017-03-06T10:24:49","slug":"unity%e3%81%ae%e5%ad%a6%e7%bf%92-part7","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/5518","title":{"rendered":"Unity\u306e\u5b66\u7fd2 part7"},"content":{"rendered":"<p>\u4eca\u56de\u306f\u3001\u30e2\u30c7\u30eb\u306e\u79fb\u52d5\u3068\u305d\u308c\u306b\u5408\u3063\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059<\/p>\n<p>\u3061\u306a\u307f\u306b\u30ed\u30fc\u30c9\u30de\u30c3\u30d7\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u304a\u308a\u307e\u3059<\/p>\n<p>\u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3057\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u30ed\u30fc\u30c9\u30de\u30c3\u30d7<br \/>\n1. <a href=\"\/appnews\/archives\/5424\">\u30e2\u30c7\u30eb\u306e\u53d6\u5f97\u3068\u914d\u7f6e\u3000<\/a><br \/>\n2. <a href=\"\/appnews\/archives\/5466\">\u30e2\u30c7\u30eb\u306b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a<\/a><br \/>\n3. \u30e2\u30c7\u30eb\u306e\u79fb\u52d5\u306b\u5408\u308f\u305b\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u3000<span style=\"color: #7f270a;\">\u2190\u4eca\u56de\u306e\u8a18\u4e8b<\/span><br \/>\n4. \u30e2\u30c7\u30eb\u3092\u8ffd\u5c3e\u3059\u308b\u30ab\u30e1\u30e9\u306e\u8a2d\u5b9a<\/p>\n<p>\u76ee\u6a19\u306f\u3001\u30e2\u30c7\u30eb\u306e\u52d5\u304b\u3057\u65b9\u3001\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u3001\u30ab\u30e1\u30e9\u306e\u5411\u304d\u306b\u5408\u308f\u305b\u305f\u79fb\u52d5\u306e\u4ed5\u65b9\u3092\u5b66\u7fd2\u3059\u308b\u3053\u3068\u3067\u3059<br \/>\n<!--more--><\/p>\n<h3>\u30e2\u30c7\u30eb\u306e\u79fb\u52d5<\/h3>\n<p>\u30e2\u30c7\u30eb\u306e\u79fb\u52d5\u306f\u3001\u524d\u5f8c\u306e\u307f\u3068\u3057\u3066\u4f5c\u6210\u3057\u307e\u3059<br \/>\n\u5de6\u53f3\u306e\u5165\u529b\u306f\u3001\u30b3\u30f3\u30c6\u30f3\u30c4\u306b\u3088\u3063\u3066\u6271\u3044\u304c\u3053\u3068\u306a\u308b\u306e\u3067\u3001\u4eca\u56de\u306f\u4f5c\u6210\u3057\u307e\u305b\u3093<\/p>\n<p>\u524d\u5f8c\u306e\u79fb\u52d5\u306f\u3001\u30ad\u30fc\u5165\u529b\u3067\u884c\u3044\u305f\u3044\u306e\u3067<span style=\"color: #0000ff;\">Input<\/span>\u3092\u4f7f\u3063\u3066\u53d6\u5f97\u3057\u3066\u3044\u304d\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 1px; padding-left: 5px;\"><code>    State state;\r\n    enum State\r\n    {\r\n        Stop,\r\n        Up,\r\n        Down,\r\n    }\r\n\r\n    private void FixedUpdate()\r\n    {\r\n        \/\/\u5165\u529b\u306e\u611f\u77e5\r\n        if (Input.GetKey(KeyCode.UpArrow))\r\n        {\r\n            state = State.Up;\r\n        }else if (Input.GetKey(KeyCode.DownArrow))\r\n        {\r\n            state = State.Down;\r\n        }\r\n        else\r\n        {\r\n            state = State.Stop;\r\n        }\r\n    }\r\n<\/code><\/pre>\n<p>\u4e0a\u30ad\u30fc\u306e\u5165\u529b\u306a\u3089\u3070\u30b9\u30c6\u30fc\u30bf\u30b9\u3092Up\u306b\u3057\u3066\u3001\u4e0b\u30ad\u30fc\u306e\u5165\u529b\u306a\u3089\u3070Down\u306b\u3057\u3066\u3001\u305d\u308c\u4ee5\u5916\u306a\u3089Stop\u306b\u3057\u307e\u3059<br \/>\n\u3053\u308c\u3067\u30ad\u30fc\u5165\u529b\u3067\u3001\u79fb\u52d5\u3059\u308b\u4e0b\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f<br \/>\n\u3042\u3068\u306f\u3001\u3053\u308c\u3092\u3082\u3068\u306b\u79fb\u52d5\u3055\u305b\u3066\u3044\u304d\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 1px; padding-left: 5px;\"><code>    Vector3 vector = Vector3.forward;\r\n\r\n    void Update () {\r\n       if(state == State.Up)\r\n        {\r\n            transform.position += vector * Time.deltaTime;\r\n        }\r\n    }\r\n<\/code><\/pre>\n<p>Vector3.forward\u306fz\u65b9\u5411\u306b+1\u306e\u307f\u3092\u6301\u3064Vector\u3092\u53d7\u3051\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059<\/p>\n<p>\u3053\u308c\u3067\u3001\u4e0a\u30ad\u30fc\u3092\u62bc\u3057\u7d9a\u3051\u308b\u3068\u524d\u306b\u9032\u3080\u3088\u3046\u306b\u306a\u308a\u307e\u3059<br \/>\n\u9032\u3080\u65b9\u5411\u306b<strong><span style=\"color: #0000ff;\">deltaTime<\/span><\/strong>\u3092\u304b\u3051\u308b\u306e\u306f\u30011\u79d2\u30671m\u9032\u307e\u305b\u308b\u305f\u3081\u306e\u51e6\u7406\u306b\u306a\u308a\u307e\u3059<br \/>\ndeltaTime\u306f\u524d\u56de\u306e\u30d5\u30ec\u30fc\u30e0\u66f4\u65b0\u304b\u3089\u306e\u5dee\u5206\u3092\u8fd4\u3057\u3066\u304f\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059<\/p>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-5520\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2017\/03\/movefront.gif\" alt=\"movefront\" width=\"693\" height=\"405\" \/><\/p>\n<p>\u524d\u306b\u9032\u3080\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u305f\u3089\u3001\u4e0b\u30ad\u30fc\u306e\u5165\u529b\u6642\u3082\u540c\u69d8\u306b\u3057\u3066\u3044\u304d\u307e\u3059<\/p>\n<h3>\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a<\/h3>\n<p>\u6700\u521d\u306b\u3001\u958b\u59cb\u6642\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3057\u307e\u3059<br \/>\nState\u3092\u65b0\u898f\u3067\u4f5c\u6210\u3057\u3066\u3001Entry\u304b\u3089\u77e2\u5370\u3092\u4f38\u3070\u3057\u307e\u3059<br \/>\n\u4f5c\u6210\u3057\u305fState\u306e\u540d\u524d\u3092Pause\u306b\u5909\u3048\u3066\u3001Motion\u3092\u597d\u304d\u306a\u3082\u306e\u306b\u3057\u307e\u3057\u3087\u3046<br \/>\n\u3053\u308c\u3067\u521d\u671f\u72b6\u614b\u306e\u8a2d\u5b9a\u306f\u5b8c\u4e86\u3067\u3059<\/p>\n<p>\u6b21\u306b\u3001\u524d\u9032\u6642\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059<br \/>\n\u5148\u307b\u3069\u3068\u540c\u3058\u3088\u3046\u306b\u3001State\u3092\u4f5c\u6210\u3057\u3066\u76f8\u4e92\u306b\u77e2\u5370\u3092\u4f38\u3070\u3057\u307e\u3059<br \/>\n\u540d\u524d\u306fFront\u306b\u3067\u3082\u3057\u307e\u3057\u3087\u3046<br \/>\nMotion\u306fWALK00_F\u306b\u3057\u307e\u3059<\/p>\n<p>\u305d\u3057\u305f\u3089\u3001\u3069\u3046\u3044\u3046\u72b6\u614b\u306e\u5834\u5408\u306b\u9077\u79fb\u3059\u308b\u304b\u3092\u6c7a\u5b9a\u3057\u307e\u3059<br \/>\n\u3053\u3053\u3067\u306f\u3001Bool\u3067Parameter\u3092\u4f5c\u6210\u3057\u307e\u3059<br \/>\nParameter\u306e\u540d\u524d\u306fFront\u306b\u3057\u3066\u304a\u304d\u307e\u3059<br \/>\nFront\u304cfalse\u306e\u5834\u5408\u306b\u306f\u3001Pause\u3078<br \/>\nFront\u304ctrue\u306e\u5834\u5408\u306b\u306f\u3001Front\u3078\u9077\u79fb\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 1px; padding-left: 5px;\"><code>    void Update () {\r\n       if(state == State.Up)\r\n        {\r\n            animator.SetBool(\"Front\", true);\r\n            transform.position += vector * Time.deltaTime;\r\n        }else\r\n        {\r\n            animator.SetBool(\"Front\", false);\r\n        }\r\n    }\r\n<\/code><\/pre>\n<p><strong><span style=\"color: #0000ff;\">animator.SetBool\u3067\u5148\u307b\u3069\u8a2d\u5b9a\u3057\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u5024\u3092\u30bb\u30c3\u30c8<\/span><\/strong>\u3057\u3066\u3044\u307e\u3059<br \/>\n\u30b9\u30c6\u30fc\u30bf\u30b9\u304cUp\u306e\u72b6\u614b\u3067\u306f\u3001Front\u30d1\u30e9\u30e1\u30fc\u30bf\u306btrue\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059<br \/>\n\u305d\u308c\u4ee5\u5916\u3067\u306f\u3001false\u3092\u30bb\u30c3\u30c8\u3057\u3066Puase\u72b6\u614b\u306b\u623b\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-5522\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2017\/03\/frontMove.gif\" alt=\"frontMove\" width=\"693\" height=\"405\" \/><\/p>\n<p>\u3053\u308c\u3092\u3001\u5f8c\u9032\u3082\u540c\u69d8\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059<\/p>\n<p>\u6700\u7d42\u7684\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u306a\u308a\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 1px; padding-left: 5px;\"><code>using UnityEngine;\r\n\r\npublic class unitychan : MonoBehaviour {\r\n    Animator animator;\r\n    State state;\r\n    Vector3 vector = Vector3.forward;\r\n\r\n    enum State\r\n    {\r\n        Stop,\r\n        Up,\r\n        Down,\r\n    }\r\n\r\n\tvoid Start () {\r\n        \/\/\u6700\u521d\u306bunitycahn\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304b\u3089Animator\u3092\u53d6\u5f97\r\n        animator = GetComponent();\r\n        state = State.Stop;\r\n\t}\r\n\t\r\n\tvoid Update () {\r\n       if(state == State.Up)\r\n        {\r\n            animator.SetBool(\"Front\", true);\r\n            transform.position += vector * Time.deltaTime;\r\n        }else if (state == State.Down)\r\n        {\r\n            animator.SetBool(\"Back\", true);\r\n            transform.position -= vector * Time.deltaTime;\r\n        }else\r\n        {\r\n            animator.SetBool(\"Back\", false);\r\n            animator.SetBool(\"Front\", false);\r\n        }\r\n    }\r\n\r\n    private void FixedUpdate()\r\n    {\r\n        \/\/\u5165\u529b\u306e\u611f\u77e5\r\n        if (Input.GetKey(KeyCode.UpArrow))\r\n        {\r\n            state = State.Up;\r\n        }else if (Input.GetKey(KeyCode.DownArrow))\r\n        {\r\n            state = State.Down;\r\n        }\r\n        else\r\n        {\r\n            state = State.Stop;\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-5526\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2017\/03\/frontMovePouse-.gif\" alt=\"frontMovePouse\" width=\"693\" height=\"405\" \/><\/p>\n<p>\u3053\u308c\u3067\u524d\u5f8c\u306e\u79fb\u52d5\u3068\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u5b8c\u4e86\u3067\u3059<\/p>\n<h3>\u7d42\u308f\u308a\u306b<\/h3>\n<p>\u4eca\u56de\u306f\u3001\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u3092\u4f7f\u7528\u3057\u305f\u30b3\u30f3\u30c6\u30f3\u30c4\u3067\u5171\u901a\u3068\u601d\u3048\u308b\u3001\u524d\u5f8c\u306e\u307f\u306e\u79fb\u52d5\u3068\u305d\u306e\u79fb\u52d5\u306b\u5408\u308f\u305b\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u30013D\u30b3\u30f3\u30c6\u30f3\u30c4\u3067\u306f\u3001\u57fa\u672c\u7684\u306b\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u306f\u524d\u5f8c\u5de6\u53f3\u3078\u306e\u52d5\u304d\u3092\u3059\u308b\u3082\u306e\u3067\u3059<br \/>\n\u5de6\u53f3\u306e\u5165\u529b\u306f\u3001\u305d\u306e\u307e\u307e\u5de6\u53f3\u306b\u79fb\u52d5\u3059\u308b\u3053\u3068\u3084\u3001\u5165\u529b\u65b9\u5411\u3078\u56de\u8ee2\u3059\u308b\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u3053\u306f\u3001\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u4e2d\u3067\u64cd\u4f5c\u3057\u3084\u3059\u3044\u65b9\u6cd5\u3092\u5c0e\u5165\u3059\u308c\u3070\u3044\u3044\u3068\u601d\u3044\u307e\u3059<\/p>\n<p>\u706b\u66dc\u65e5\u62c5\u5f53\uff1apoppy<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/5518\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/5518\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Unity\u306e\u5b66\u7fd2 part7\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/5518\" data-text=\"Unity\u306e\u5b66\u7fd2 part7\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/5518\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/5518\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306f\u3001\u30e2\u30c7\u30eb\u306e\u79fb\u52d5\u3068\u305d\u308c\u306b\u5408\u3063\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059 \u3061\u306a\u307f\u306b\u30ed\u30fc\u30c9\u30de\u30c3\u30d7\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u304a\u308a\u307e\u3059 \u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3057\u305f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u30ed\u30fc\u30c9\u30de\u30c3\u30d7 1. \u30e2\u30c7\u30eb\u306e\u53d6\u5f97\u3068\u914d\u7f6e\u3000 2. \u30e2\u30c7\u30eb\u306b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100,109],"tags":[56,108,110],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/5518"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=5518"}],"version-history":[{"count":16,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/5518\/revisions"}],"predecessor-version":[{"id":5539,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/5518\/revisions\/5539"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=5518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=5518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=5518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}