{"id":2348,"date":"2020-12-29T22:51:06","date_gmt":"2020-12-29T14:51:06","guid":{"rendered":"https:\/\/www.clonefactor.com\/wordpress\/?p=2348"},"modified":"2020-12-29T22:51:07","modified_gmt":"2020-12-29T14:51:07","slug":"%e5%af%a6%e4%bd%9c%e8%b7%b3%e9%81%8e%e9%9a%9c%e7%a4%99%e7%89%a9","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/program\/unity3d\/devlog\/charactercontroller\/2348\/","title":{"rendered":"\u5be6\u4f5c\u8df3\u904e\u969c\u7919\u7269"},"content":{"rendered":"\n<p class=\"has-large-font-size\">First Attempt : Target Matching<\/p>\n\n\n\n<p>\u5be6\u4f5c <a href=\"https:\/\/docs.unity3d.com\/Manual\/TargetMatching.html\" target=\"_blank\" rel=\"noreferrer noopener\">Target Matching<\/a> \u6709\u5e7e\u500b\u8981\u9ede<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u65bc transition \u72c0\u614b\u4e2d\u4e0d\u80fd\u555f\u52d5 Target Matching \u6703\u88ab\u5ffd\u8996\u7136\u5f8c\u51fa\u73fe\u8b66\u544a.<\/li><li>\u5982\u679c\u5df2\u7d93\u8655\u65bc Target Matching \u4e2d\u9014\u51fa\u73fe transition, \u539f\u6709\u7684 Target Matching \u7684\u8655\u7406\u6703\u88ab\u4e2d\u6b62.<\/li><li>Target Matching \u7121\u8996\u7269\u7406, \u53ea\u662f\u55ae\u7d14\u7684\u65bc\u8d77\u59cb\u9ede lerp \u5230\u7d42\u9ede. rotation \u4ea6\u662f\u4e00\u6a23.<\/li><\/ul>\n\n\n\n<p>\u9019\u6b21\u5617\u8a66\u4e2d\u4f7f\u5229\u7528 Trigger box \u4f86\u6c7a\u5b9a\u8d77\u8df3\u53ca\u8457\u5730\u9ede, \u5229\u7528\u8d77\u8df3\u7684\u77ac\u9593\u7684 Transfrom position\/rotation \u4f86\u6c7a\u5b9a\u5750\u6a19\u53ca\u9762\u5411.<br>\u4f9d\u8a72\u5750\u6a19\u5411\u5411\u524d\u9806\u5ef6 2 \u500b Collider \u7684 Bound box \u8ddd\u96e2, \u5373\u53ef\u77e5\u9053\u5728\u8def\u8e01\u4e0a\u63a5\u89f8\u7684\u9ede.<br>\u518d\u4ee5\u8a72\u6700\u8fd1\u7684\u9ede(\u767d\u661f) &amp; \u6700\u9060\u7684\u9ede(\u9ec3\u661f) \u70ba\u6307\u6a19\u53d6\u5f97\u53ef\u8abf\u6574\u7684\u8457\u9678\u9ede(\u6dfa\u85cd\u8272)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"569\" src=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/12\/JumpObstacle00-1024x569.jpg\" alt=\"\" class=\"wp-image-2349\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/12\/JumpObstacle00-1024x569.jpg 1024w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/12\/JumpObstacle00-300x167.jpg 300w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/12\/JumpObstacle00-768x427.jpg 768w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/12\/JumpObstacle00-359x199.jpg 359w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2020\/12\/JumpObstacle00.jpg 1118w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Extend coordination&#8217;s facing to project the landing point.<\/figcaption><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public bool TryGetLandingPoint(int index, Vector3 pos, Vector3 facing, out Vector3 landingPoint)\n{\n\tlandingPoint = Vector3.zero;\n\n\tCollider landingZone = index == -1 ? m_DefaultJump.landingZone : m_ExtraConfig[index].landingZone;\n\tBounds both = landingZone.bounds;\n\tboth.Encapsulate(m_TriggerArea.bounds);\n\tfloat maxDistance = (both.min - both.max).magnitude;\n\n\t\/\/ Calculate facing adjustment.\n\tVector3 virtualPlaneNormal = Vector3.up;\n\tVector3 vertor = landingZone.bounds.center - m_TriggerArea.bounds.center;\n\tVector3 dir = vertor;\n\tVector3.OrthoNormalize(ref dir, ref virtualPlaneNormal);\n\tVector3 biasVertor = Vector3.Lerp(dir, facing, 0.5f);\n\tVector3 fixedFacing = Vector3.ProjectOnPlane(biasVertor, virtualPlaneNormal).normalized * maxDistance;\n\n\tif (m_Debug.gizmos)\n\t{\n\t\tDebugExtend.DrawRay(m_TriggerArea.bounds.center, vertor, Color.blue);\n\t\tDebugExtend.DrawRay(m_TriggerArea.bounds.center, virtualPlaneNormal, Color.green);\n\t\tDebugExtend.DrawRay(pos, facing * maxDistance, Color.gray);\n\t\tDebugExtend.DrawRay(pos, fixedFacing, Color.white);\n\t}\n\n\n\tRay ray = new Ray(pos, fixedFacing);\n\tif (landingZone.bounds.IntersectRay(ray))\n\t{\n\t\tVector3 near = landingZone.Raycast(ray, out RaycastHit hit, maxDistance) ?\n\t\t\thit.point :\n\t\t\tVector3Extend.NearestPointOnLine(ray.origin, ray.direction, landingZone.ClosestPoint(pos));\n\t\tVector3 far = landingZone.ClosestPoint(ray.GetPoint(maxDistance));\n\n\t\t\/\/ Project on current direction.\n\t\tfar = Vector3Extend.NearestPointOnLine(ray.origin, ray.direction, far);\n\t\tfloat weight = index == -1 ? m_DefaultJump.landingWeight : m_ExtraConfig[index].landingWeight;\n\t\tlandingPoint = Vector3.Lerp(near, far, weight);\n\n\t\tif (m_Debug.gizmos)\n\t\t{\n\t\t\tDebugExtend.DrawPoint(near, Color.white, 0.3f);\n\t\t\tDebugExtend.DrawPoint(landingPoint, Color.cyan, 0.3f);\n\t\t\tDebugExtend.DrawPoint(far, Color.yellow, 0.3f);\n\t\t}\n\t\treturn true;\n\t}\n\telse\n\t{\n\t\tDebugExtend.DrawRay(pos, fixedFacing, Color.red, 5f);\n\t}\n\treturn false;\n}<\/pre>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"mess around with MatchTarget CC #Log29\" width=\"1260\" height=\"945\" src=\"https:\/\/www.youtube.com\/embed\/jn_qgGNvdVE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u7c21\u55ae\u4f86\u8aaa\u9019\u6b21\u5be6\u9a57\u662f\u5931\u6557\u7684, \u53ea\u80fd\u7b97\u662f\u529f\u80fd\u4e0a\u5b8c\u6210\u5be6\u969b\u6839\u672c\u5230\u4e0d\u4e86 AAA \u7684\u6c34\u5e73.<br>\u4e5f\u5728 Unity3d Forum \u4e0a\u8a62\u554f\u904e\u597d\u50cf\u4e5f\u6c92\u6709\u66f4\u597d\u7684\u8fa6\u6cd5.<br><a rel=\"noreferrer noopener\" href=\"https:\/\/forum.unity.com\/threads\/how-to-implement-match-target-jump-best-practice.1027060\/#post-6659785\" data-type=\"URL\" data-id=\"https:\/\/forum.unity.com\/threads\/how-to-implement-match-target-jump-best-practice.1027060\/#post-6659785\" target=\"_blank\">https:\/\/forum.unity.com\/threads\/how-to-implement-match-target-jump-best-practice.1027060\/#post-6659785<\/a><\/p>\n\n\n\n<p>\u6240\u4ee5\u6c7a\u5b9a\u53e6\u5916\u627e\u4e00\u500b\u8fa6\u6cd5\u4f86\u5b8c\u6210.<\/p>\n\n\n\n<p>(\u5f85\u7e8c)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First Attempt : Target Matching \u5be6\u4f5c Target Matching &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[107],"tags":[116],"class_list":["post-2348","post","type-post","status-publish","format-standard","hentry","category-charactercontroller","tag-animator"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/2348","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=2348"}],"version-history":[{"count":3,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/2348\/revisions"}],"predecessor-version":[{"id":2352,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/2348\/revisions\/2352"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}