{"id":180,"date":"2022-04-17T10:59:17","date_gmt":"2022-04-17T02:59:17","guid":{"rendered":"https:\/\/www.jinhaihan.top\/WordPress\/?p=180"},"modified":"2022-04-17T10:59:18","modified_gmt":"2022-04-17T02:59:18","slug":"ue5-c-timer%e7%9a%84%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/www.jinhaihan.top\/WordPress\/ue5-c-timer%e7%9a%84%e4%bd%bf%e7%94%a8\/","title":{"rendered":"UE5 C++ Timer\u7684\u4f7f\u7528"},"content":{"rendered":"\n<div class=\"wp-block-jetpack-markdown\"><p>1.\u521b\u5efa\u4e00\u4e2a<code>FTimerHandle<\/code>\u6765\u7ba1\u7406\u8ba1\u65f6\u5668\uff0c\u4e00\u4e2a\u8ba1\u65f6\u5668\u4e00\u4e2ahandle<\/p>\n<pre><code class=\"language-C++\">FTimerHandle MyTimerHandle;\n<\/code><\/pre>\n<p>2.\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\uff0c\u7528\u4e8e\u8ba1\u65f6\u5668\u7ed3\u675f\u4e4b\u540e\u89e6\u53d1\uff1a<\/p>\n<pre><code class=\"language-C++\"> UFUNCTION()\n void OnNext();\n<\/code><\/pre>\n<p>3.\u8bbe\u7f6e\u8ba1\u65f6\u5668\uff1a<\/p>\n<pre><code class=\"language-cpp\">GetWorld()-&gt;GetTimerManager().SetTimer(MyTimerHandle, this, &amp;MyActor::OnExplode, Time, false);\n<\/code><\/pre>\n<p>3.\u6e05\u9664\u8ba1\u65f6\u5668\uff1a<\/p>\n<pre><code class=\"language-cpp\">\/\/\u6e05\u9664\u4e00\u4e2a\nGetWorld()-&gt;GetTimerManager().ClearTimer(MyTimerHandle);\n\/\/\/\u6e05\u9664\u6240\u6709\nGetWorld()-&gt;GetTimerManager().ClearAllTimersForObject(this);\n<\/code><\/pre>\n<p>4.SetTimer\u51fd\u6570\u53c2\u6570\u5b9a\u4e49\uff1a<\/p>\n<pre><code class=\"language-cpp\">\/**\n\t * Sets a timer to call the given native function at a set interval.  If a timer is already set\n\t * for this handle, it will replace the current timer.\n\t *\n\t * @param InOutHandle\t\t\tIf the passed-in handle refers to an existing timer, it will be cleared before the new timer is added. A new handle to the new timer is returned in either case.\n\t * @param InObj\t\t\t\t\tObject to call the timer function on.\n\t * @param InTimerMethod\t\t\tMethod to call when timer fires.\n\t * @param InRate\t\t\t\tThe amount of time (in seconds) between set and firing.  If &lt;= 0.f, clears existing timers.\n\t * @param InbLoop\t\t\t\ttrue to keep firing at Rate intervals, false to fire only once.\n\t * @param InFirstDelay\t\t\tThe time (in seconds) for the first iteration of a looping timer. If &lt; 0.f InRate will be used.\n\t *\/\n\ttemplate&lt; class UserClass &gt;\n\tFORCEINLINE void SetTimer(FTimerHandle&amp; InOutHandle, UserClass* InObj, typename FTimerDelegate::TMethodPtr&lt; UserClass &gt; InTimerMethod, float InRate, bool InbLoop = false, float InFirstDelay = -1.f)\n\t{\n\t\tInternalSetTimer(InOutHandle, FTimerUnifiedDelegate( FTimerDelegate::CreateUObject(InObj, InTimerMethod) ), InRate, InbLoop, InFirstDelay);\n\t}\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":182,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[7,13],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/04\/backiee-212913-scaled.jpg?fit=2560%2C1440&ssl=1","jetpack-related-posts":[{"id":192,"url":"https:\/\/www.jinhaihan.top\/WordPress\/ue5-ik-retarget-%e9%87%8d%e5%ae%9a%e5%90%91%e5%8a%a8%e7%94%bb%e6%b2%a1%e6%9c%89rootmotion%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95\/","url_meta":{"origin":180,"position":0},"title":"UE5 IK Retarget \u91cd\u5b9a\u5411\u52a8\u753b\u6ca1\u6709RootMotion\u7684\u89e3\u51b3\u65b9\u6cd5","author":"Kim","date":"2022\u5e747\u67088\u65e5","format":false,"excerpt":"\u5c0f\u7ec6\u8282\uff0c\u5728IK Retarget\u7684\u8282\u70b9Chain Mapping\u91cc\u9762\u53ef\u4ee5\u8bbe\u7f6e\u6bcf\u4e2a\u8282\u70b9\u7684\u91cd\u5b9a\u5411\u65b9\u5f0f\uff0c\u70b9\u2026","rel":"","context":"\u5728\u201c\u535a\u5ba2\u201d\u4e2d","block_context":{"text":"\u535a\u5ba2","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/"},"img":{"alt_text":"landscape photograph of body of water","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/pexels-photo-1001682.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/pexels-photo-1001682.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/pexels-photo-1001682.jpeg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/pexels-photo-1001682.jpeg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":162,"url":"https:\/\/www.jinhaihan.top\/WordPress\/c-%e7%94%9f%e6%88%90%e8%93%9d%e5%9b%be%e7%b1%bb%e5%af%b9%e8%b1%a1\/","url_meta":{"origin":180,"position":1},"title":"C++ \u751f\u6210\u84dd\u56fe\u7c7b\u5bf9\u8c61","author":"Kim","date":"2022\u5e743\u67082\u65e5","format":false,"excerpt":"\u83b7\u53d6\u84dd\u56fe\u8d44\u6e90\u8def\u5f84 \u5728UE\u4e2d\u53f3\u952e\u8d44\u6e90\uff0c\u9009\u62e9Copy Reference\u5373\u53ef\uff0c\u540e\u7eed\u7528\u5230\u7684\u8def\u5f84\u3001Name\u90fd\u2026","rel":"","context":"\u5728\u201c\u535a\u5ba2\u201d\u4e2d","block_context":{"text":"\u535a\u5ba2","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/03\/R.jpg?fit=1200%2C750&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/03\/R.jpg?fit=1200%2C750&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/03\/R.jpg?fit=1200%2C750&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/03\/R.jpg?fit=1200%2C750&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":184,"url":"https:\/\/www.jinhaihan.top\/WordPress\/ue4-c%e7%bb%91%e5%ae%9a%e6%8c%89%e9%94%ae%e8%be%93%e5%85%a5\/","url_meta":{"origin":180,"position":2},"title":"UE4 C++\u7ed1\u5b9a\u6309\u952e\u8f93\u5165","author":"Kim","date":"2022\u5e744\u670817\u65e5","format":false,"excerpt":"Actor\u5185\u6709\u4e00\u4e2a\u5df2\u7ecf\u9884\u5148\u5b9a\u4e49\u7684InputComponent \u9700\u8981\u5c06\u5176\u8fdb\u884c\u5b9e\u4f8b\u5316\u3001\u7ed1\u5b9a\u5373\u53ef, \u6700\u540e\u8981\u2026","rel":"","context":"\u5728\u201c\u535a\u5ba2\u201d\u4e2d","block_context":{"text":"\u535a\u5ba2","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/03\/R.jpg?fit=1200%2C750&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/03\/R.jpg?fit=1200%2C750&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/03\/R.jpg?fit=1200%2C750&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/03\/R.jpg?fit=1200%2C750&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":235,"url":"https:\/\/www.jinhaihan.top\/WordPress\/%e5%9c%a8gin%e6%a1%86%e6%9e%b6%e4%b8%ad%e8%8e%b7%e5%8f%96%e5%a4%96%e9%83%a8%e8%af%b7%e6%b1%82%e4%b8%adget%e5%92%8cpost%e7%9a%84%e5%8f%82%e6%95%b0\/","url_meta":{"origin":180,"position":3},"title":"\u5728Gin\u6846\u67b6\u4e2d\u83b7\u53d6\u5916\u90e8\u8bf7\u6c42\u4e2dGet\u548cPost\u7684\u53c2\u6570","author":"Kim","date":"2023\u5e741\u670831\u65e5","format":false,"excerpt":"\u9996\u5148\u5047\u8bbe\u5df2\u7ecf\u642d\u5efa\u597d\u6574\u4e2a\u670d\u52a1\uff0c\u5e76\u521b\u5efa\u4e86\u51e0\u4e2aAPI\u7528\u4e8e\u6d4b\u8bd5\u3002 \u5728Get\u8bf7\u6c42\u4e2d\uff0c\u5047\u8bbe\u7531\u4ee5\u4e0b\u51fd\u6570\u5904\u7406\uff0c\u5219\u83b7\u53d6\u2026","rel":"","context":"\u5728\u201cGolang\u201d\u4e2d","block_context":{"text":"Golang","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/golang\/"},"img":{"alt_text":"Dynamic Earth - Ocean Currents","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2023\/01\/7402441936_5c99447ca0_b.jpg?fit=1024%2C576&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2023\/01\/7402441936_5c99447ca0_b.jpg?fit=1024%2C576&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2023\/01\/7402441936_5c99447ca0_b.jpg?fit=1024%2C576&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":81,"url":"https:\/\/www.jinhaihan.top\/WordPress\/%e5%9c%a8ai%e9%bb%91%e6%9d%bf%e4%b8%ad%e4%bd%bf%e7%94%a8c%e7%9a%84%e6%9e%9a%e4%b8%be\/","url_meta":{"origin":180,"position":4},"title":"\u5728AI\u9ed1\u677f\u4e2d\u4f7f\u7528C++\u7684\u679a\u4e3e","author":"Kim","date":"2021\u5e749\u67089\u65e5","format":false,"excerpt":"\u5728\u84dd\u56fe\u9ed1\u677f\u4e2d\u9009\u62e9\u679a\u4e3e\uff0c\u5c06\u4f1a\u627e\u4e0d\u5230C++\u7684\u679a\u4e3e\u9009\u9879 \u6b64\u65f6\u4e0d\u8981\u5728EnumType\u4e2d\u5bfb\u627e\uff0c\u76f4\u63a5\u5c06\u679a\u4e3e\u7c7b\u540d\u586b\u2026","rel":"","context":"\u5728\u201c\u865a\u5e7b4\/5\u201d\u4e2d","block_context":{"text":"\u865a\u5e7b4\/5","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/unreal-engine\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/504777bc844f1410df167b4f625b0136.jpg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/504777bc844f1410df167b4f625b0136.jpg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/504777bc844f1410df167b4f625b0136.jpg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/504777bc844f1410df167b4f625b0136.jpg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":87,"url":"https:\/\/www.jinhaihan.top\/WordPress\/cai%e4%b8%ad%e5%88%87%e6%8d%a2blackboard%e7%9a%84%e5%80%bc\/","url_meta":{"origin":180,"position":5},"title":"C++AI\u4e2d\u5207\u6362BlackBoard\u7684\u503c","author":"Kim","date":"2021\u5e749\u67089\u65e5","format":false,"excerpt":"\u9996\u5148\u5b9a\u4e49\u4e00\u4e2aFBlackboardKeySelector UPROPERTY(EditAnywher\u2026","rel":"","context":"\u5728\u201c\u865a\u5e7b4\/5\u201d\u4e2d","block_context":{"text":"\u865a\u5e7b4\/5","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/unreal-engine\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/888563.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/888563.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/888563.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/888563.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts\/180"}],"collection":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":1,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":183,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts\/180\/revisions\/183"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/media\/182"}],"wp:attachment":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}