{"id":1897,"date":"2017-12-30T06:04:01","date_gmt":"2017-12-29T22:04:01","guid":{"rendered":"http:\/\/www.clonefactor.com\/wordpress\/?p=1897"},"modified":"2017-12-30T22:33:36","modified_gmt":"2017-12-30T14:33:36","slug":"sandbox-webgl-test","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/program\/1897\/","title":{"rendered":"Sandbox Finger control log 3 + WebGL test"},"content":{"rendered":"<p><a href=\"http:\/\/clonefactor.com\/20171230_DaughterSandbox_Data\/\">http:\/\/clonefactor.com\/20171230_DaughterSandbox_Data\/<\/a><\/p>\n<div class=\"aio-button-center\"><div class=\"aio-flash\"><a target=\"_blank\" href=\"http:\/\/clonefactor.com\/20171230_DaughterSandbox_Data\/\" class=\"aio-orange-medium\" title=\"Play Demo\"><i class=\"glyphicons glyphicons-gamepad x2\"><\/i>Play Demo<\/a><\/div><\/div>\n<p>Demo record :<\/p>\n<p><iframe loading=\"lazy\" title=\"Finger control physical #log 3\" width=\"1260\" height=\"945\" src=\"https:\/\/www.youtube.com\/embed\/9VhFXmAdoPg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/p>\n<p>\u5728\u7269\u7406\u6e2c\u8a66\u4e2d,unity3D\u4eba\u7269\u7684ragdoll \u8a2d\u5b9a\u5176\u5be6\u5f88\u7c21\u964b, \u770b\u4f86\u8981\u505a\u4e00\u500b\u81ea\u7136\u7684\u6b7b\u5c4d\u4e5f\u6709\u4e00\u5b9a\u7684\u529f\u592b\u8981\u505a.<\/p>\n<p>\u4e5f\u9806\u9053\u5206\u4eab\u4e00\u500b\u7c21\u55ae\u7684\u651d\u50cf\u982d\u5beb\u6cd5, \u56e0\u70ba\u6e2c\u8a66\u6642\u5e0c\u671b\u5feb\u901f\u9032\u5165 Game Mode \u800c\u53c8\u61f6\u60f0\u7684\u95dc\u4fc2.<br \/>\n\u6240\u4ee5\u9810\u5148\u505a\u597d\u4e86\u8ddf Unity3D \u6709 80% \u76f8\u4f3c\u7684\u93e1\u982d\u52d5\u4f5c Script,<br \/>\n\u9700\u8981\u6642\u76f4\u63a5\u653e\u5230 Camera \u5143\u4ef6\u4e0a\u5373\u53ef. \u5e73\u53f0\u662f PC + Editor \u9650\u5b9a.<\/p>\n<p>\u53c8\u6c92\u6709\u9054\u5230\u53ef\u4ee5\u767c\u552e\u7684\u7a0b\u5ea6\u6240\u4ee5\u76f4\u63a5\u5728\u9019\u908a\u516c\u958b\u5206\u4eab\u7b97\u4e86.<br \/>\n\u6709\u7528\u8655\u7684\u96a8\u4fbf, \u6709\u5efa\u8b70\u7684\u4e5f\u6b61\u8fce\u63d0\u9ede\u4e00\u4e0b <del datetime=\"2017-12-30T14:19:56+00:00\">(e.g. \u624b\u6a5f\u652f\u6301\u7b49\u7b49&#8230;.)<\/del><\/p>\n<p>Known bugs:<\/p>\n<p>\u597d\u50cf\u5728 WebGL \u74b0\u5883\u9700\u8981 Right + \u4efb\u4f55\u5176\u4ed6\u9375\u624d\u80fd\u5920\u6210\u529f\u89f8\u767c. \u539f\u56e0\u61c9\u8a72\u662f HTML \u7684 context menu. \u4e0d\u904e\u90a3\u662f\u7cfb\u7d71\u7684 bug.<\/p>\n<p><strong>ObserverMovement.cs<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">using UnityEngine;\r\nusing UnityEngine.Networking;\r\n\r\nnamespace Kit\r\n{\r\n\tpublic class ObserverMovement : MonoBehaviour\r\n\t{\r\n\t\t[Header(\"Common\")]\r\n\t\tpublic float m_Speed = 0.5f;\r\n\t\tpublic float m_HighSpeed = 2f;\r\n\r\n\t\t[Header(\"Optional\")]\r\n\t\tpublic NetworkIdentity m_NetworkIdentity;\r\n\t\tpublic Camera m_Camera;\r\n\r\n\t\tprivate float m_CurrentSpeed = 0f;\r\n\t\tprivate bool m_ToggleSpeed = false;\r\n\t\tprivate Vector3 m_LocalTranslate = Vector3.zero;\r\n\t\tprivate Vector2 m_LocalLook = Vector2.zero;\r\n\r\n\t\tvoid OnValidate()\r\n\t\t{\r\n\t\t\tif (m_NetworkIdentity == null)\r\n\t\t\t{\r\n\t\t\t\tm_NetworkIdentity = GetComponent&lt;NetworkIdentity&gt;();\r\n\t\t\t}\r\n\r\n\t\t\tif (m_NetworkIdentity != null)\r\n\t\t\t{\r\n\t\t\t\tif (m_Camera == null)\r\n\t\t\t\t\tm_Camera = GetComponentInChildren&lt;Camera&gt;(true);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tvoid InputUpdate()\r\n\t\t{\r\n\t\t\t\/\/ Mouse look\r\n\t\t\tif ((Input.GetMouseButton(1) || Input.GetMouseButton(2)) &amp;&amp;\r\n\t\t\t\tCursor.lockState != CursorLockMode.Locked)\r\n\t\t\t{\r\n\t\t\t\tCursor.lockState = CursorLockMode.Locked;\r\n\t\t\t}\r\n\t\t\tif ((Input.GetMouseButtonUp(1) || Input.GetMouseButtonUp(2)) &amp;&amp;\r\n\t\t\t\tCursor.lockState != CursorLockMode.None)\r\n\t\t\t{\r\n\t\t\t\tCursor.lockState = CursorLockMode.None;\r\n\t\t\t}\r\n\r\n\t\t\tif (Cursor.lockState == CursorLockMode.Locked)\r\n\t\t\t{\r\n\t\t\t\tm_LocalLook.x = -Input.GetAxis(\"Mouse Y\");\r\n\t\t\t\tm_LocalLook.y = Input.GetAxis(\"Mouse X\");\r\n\t\t\t}\r\n\r\n\t\t\t\/\/ Speed\r\n\t\t\tif (!m_ToggleSpeed &amp;&amp;\r\n\t\t\t\tInput.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift))\r\n\t\t\t{\r\n\t\t\t\tm_ToggleSpeed = true;\r\n\t\t\t}\r\n\t\t\telse if (m_ToggleSpeed &amp;&amp;\r\n\t\t\t\t(Input.GetKeyUp(KeyCode.LeftShift) || Input.GetKeyUp(KeyCode.RightShift)) &amp;&amp;\r\n\t\t\t\t!(Input.GetKey(KeyCode.LeftShift) &amp;&amp; Input.GetKey(KeyCode.RightShift)))\r\n\t\t\t{\r\n\t\t\t\tm_ToggleSpeed = false;\r\n\t\t\t}\r\n\t\t\tm_CurrentSpeed = (m_ToggleSpeed) ? m_HighSpeed : m_Speed;\r\n\r\n\t\t\t\/\/ Movement\r\n\t\t\tif (Input.GetAxis(\"Vertical\") != 0)\r\n\t\t\t{\r\n\t\t\t\tm_LocalTranslate += transform.forward * m_CurrentSpeed * Input.GetAxis(\"Vertical\");\r\n\t\t\t}\r\n\t\t\tif (Input.GetAxis(\"Horizontal\") != 0)\r\n\t\t\t{\r\n\t\t\t\tm_LocalTranslate += transform.right * m_CurrentSpeed * Input.GetAxis(\"Horizontal\");\r\n\t\t\t}\r\n\r\n\t\t\tif (Input.GetKey(KeyCode.E) &amp;&amp; !Input.GetKey(KeyCode.Q))\r\n\t\t\t{\r\n\t\t\t\tm_LocalTranslate += transform.up * m_CurrentSpeed * 0.5f;\r\n\t\t\t}\r\n\t\t\tif (Input.GetKey(KeyCode.Q) &amp;&amp; !Input.GetKey(KeyCode.E))\r\n\t\t\t{\r\n\t\t\t\tm_LocalTranslate += -transform.up * m_CurrentSpeed * 0.5f;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvoid Update()\r\n\t\t{\r\n\t\t\tif (m_NetworkIdentity != null &amp;&amp; !m_NetworkIdentity.isLocalPlayer)\r\n\t\t\t{\r\n\t\t\t\tNetworkNPCUpdate();\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tLocalPlayerUpdate();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvoid NetworkNPCUpdate()\r\n\t\t{\r\n\t\t\tif (m_Camera != null)\r\n\t\t\t\tm_Camera.enabled = false;\r\n\t\t}\r\n\r\n\t\tvoid LocalPlayerUpdate()\r\n\t\t{\r\n\t\t\tInputUpdate();\r\n\r\n\t\t\t\/\/ Apply\r\n\t\t\ttransform.Translate(m_LocalTranslate, Space.World);\r\n\t\t\tif (Cursor.lockState == CursorLockMode.Locked)\r\n\t\t\t{\r\n\t\t\t\ttransform.Rotate(Vector3.right, m_LocalLook.x, Space.Self);\r\n\t\t\t\ttransform.Rotate(Vector3.up, m_LocalLook.y, Space.World);\r\n\t\t\t}\r\n\r\n\t\t\t\/\/ Reset\r\n\t\t\tm_LocalTranslate = Vector3.zero;\r\n\t\t\tm_LocalLook = Vector2.zero;\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/clonefactor.com\/20171230_DaughterSandbox_Da &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,11,4],"tags":[43],"class_list":["post-1897","post","type-post","status-publish","format-standard","hentry","category-c","category-unity3d","category-program","tag-unity3d-2"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1897"}],"version-history":[{"count":0,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1897\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}