{"id":3176,"date":"2018-10-06T04:44:13","date_gmt":"2018-10-05T19:44:13","guid":{"rendered":"http:\/\/nantoka.filmm.info\/blog\/?p=3176"},"modified":"2018-10-06T06:21:06","modified_gmt":"2018-10-05T21:21:06","slug":"ultimate-joystick-cam","status":"publish","type":"post","link":"https:\/\/nantoka.filmm.info\/blog\/?p=3176","title":{"rendered":"Ultimate Joystick cam"},"content":{"rendered":"<p>ultimate joystick\u7528\u30b9\u30af\u30ea\u30d7\u30c8<\/p>\n<pre class=\"lang:default decode:true \">\/\/ BEGIN MIT LICENSE BLOCK \/\/\r\n\/\/\r\n\/\/ Copyright (c) 2016 dskjal\r\n\/\/ This software is released under the MIT License.\r\n\/\/ http:\/\/opensource.org\/licenses\/mit-license.php\r\n\/\/\r\n\/\/ END MIT LICENSE BLOCK   \/\/\r\nusing UnityEngine;\r\n\r\n[RequireComponent(typeof(Camera))]\r\npublic class followCam3 : MonoBehaviour\r\n{\r\n    public Transform Target;\r\n    public float DistanceToPlayerM = 2f;    \/\/ \u30ab\u30e1\u30e9\u3068\u30d7\u30ec\u30a4\u30e4\u30fc\u3068\u306e\u8ddd\u96e2[m]\r\n    public float SlideDistanceM = 0f;       \/\/ \u30ab\u30e1\u30e9\u3092\u6a2a\u306b\u30b9\u30e9\u30a4\u30c9\u3055\u305b\u308b\uff1b\u30d7\u30e9\u30b9\u306e\u6642\u53f3\u3078\uff0c\u30de\u30a4\u30ca\u30b9\u306e\u6642\u5de6\u3078[m]\r\n    public float HeightM = 1.2f;            \/\/ \u6ce8\u8996\u70b9\u306e\u9ad8\u3055[m]\r\n    public float RotationSensitivity = 100f;\/\/ \u611f\u5ea6\r\n    public float limitMax = 0.4f;\r\n    public float limitMin = -0.4f;\r\n\r\n    void Start()\r\n    {\r\n        if (Target == null)\r\n        {\r\n            Debug.LogError(\"\u30bf\u30fc\u30b2\u30c3\u30c8\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\");\r\n            Application.Quit();\r\n        }\r\n    }\r\n\r\n    void FixedUpdate()\r\n    {\r\n\r\n\r\n       \/\/ var rotX = Input.GetAxis(\"Mouse X\") * Time.deltaTime * RotationSensitivity;\r\n       \/\/ var rotY = Input.GetAxis(\"Mouse Y\") * Time.deltaTime * RotationSensitivity;\r\n\r\n        float rotX = UltimateJoystick.GetHorizontalAxis(\"camStick\")* Time.deltaTime * RotationSensitivity;\r\n        float rotY = UltimateJoystick.GetVerticalAxis(\"camStick\")* Time.deltaTime * RotationSensitivity;\r\n\r\n        var lookAt = Target.position + Vector3.up * HeightM;\r\n\r\n        \/\/ \u56de\u8ee2\r\n        transform.RotateAround(lookAt, Vector3.up, rotX);\r\n        \/\/ \u30ab\u30e1\u30e9\u304c\u30d7\u30ec\u30a4\u30e4\u30fc\u306e\u771f\u4e0a\u3084\u771f\u4e0b\u306b\u3042\u308b\u3068\u304d\u306b\u305d\u308c\u4ee5\u4e0a\u56de\u8ee2\u3055\u305b\u306a\u3044\u3088\u3046\u306b\u3059\u308b\r\n        if (transform.forward.y &gt; limitMax &amp;&amp; rotY &lt; 0)\/\/default 0.9\r\n        {\r\n            rotY = 0;\r\n        }\r\n        if (transform.forward.y &lt; limitMin &amp;&amp; rotY &gt; 0)\r\n        {\r\n            rotY = 0;\r\n        }\r\n        transform.RotateAround(lookAt, transform.right, rotY);\r\n\r\n        \/\/ \u30ab\u30e1\u30e9\u3068\u30d7\u30ec\u30a4\u30e4\u30fc\u3068\u306e\u9593\u306e\u8ddd\u96e2\u3092\u8abf\u6574\r\n        transform.position = lookAt - transform.forward * DistanceToPlayerM;\r\n\r\n        \/\/ \u6ce8\u8996\u70b9\u306e\u8a2d\u5b9a\r\n        transform.LookAt(lookAt);\r\n\r\n        \/\/ \u30ab\u30e1\u30e9\u3092\u6a2a\u306b\u305a\u3089\u3057\u3066\u4e2d\u592e\u3092\u958b\u3051\u308b\r\n        transform.position = transform.position + transform.right * SlideDistanceM;\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>\u53c2\u8003\u30b5\u30a4\u30c8<\/p>\n<p>https:\/\/dskjal.com\/unity\/tps-camera.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ultimate joystick\u7528\u30b9\u30af\u30ea\u30d7\u30c8 \/\/ BEGIN MIT LICENSE BLOCK \/\/ \/\/ \/\/ Copyright (c) 2016 dskjal \/\/ This software is rele &hellip; <a href=\"https:\/\/nantoka.filmm.info\/blog\/?p=3176\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">Ultimate Joystick cam<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,2],"tags":[],"class_list":["post-3176","post","type-post","status-publish","format-standard","hentry","category-c","category-unity"],"_links":{"self":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3176"}],"version-history":[{"count":2,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3176\/revisions"}],"predecessor-version":[{"id":3178,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3176\/revisions\/3178"}],"wp:attachment":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}