{"id":1347,"date":"2024-01-12T23:15:44","date_gmt":"2024-01-12T21:15:44","guid":{"rendered":"https:\/\/www.rocworks.at\/wordpress\/?p=1347"},"modified":"2024-06-22T06:57:35","modified_gmt":"2024-06-22T04:57:35","slug":"mqtt-for-gaming","status":"publish","type":"post","link":"https:\/\/www.rocworks.at\/wordpress\/?p=1347","title":{"rendered":"MQTT for Gaming?"},"content":{"rendered":"\n<p>MQTT for Multiplayer Games? I am not a Game-Developer and I do not know how they create multiplayer internet games. But I know that MQTT can be used for that. Why?<\/p>\n\n\n\n<p># IoT turns to IoP<\/p>\n\n\n\n<p>MQTT is used for connecting devices. Think about using MQTT for connecting players. &#8220;Internet of Things&#8221; (IoT) will turn to \u201eInternet of Players\u201c (IoP).<\/p>\n\n\n\n<p># A Player is like a Device?<\/p>\n\n\n\n<p>In a multiplayer game, each player is like a device. When they join the game, it&#8217;s like they&#8217;re saying &#8220;Hello, I&#8217;m here!&#8221; to everyone else \u2013 this is known as a &#8220;birth message&#8221; in MQTT terms.<\/p>\n\n\n\n<p># Sharing Information Seamlessly<\/p>\n\n\n\n<p>As players move around in the game, they keep sending updates like their location, healthy state, collected goodies, \u2026. MQTT acts like a messenger, picking up this information and delivering it to everyone else playing.&nbsp;<\/p>\n\n\n\n<p># Handling Player Exits<\/p>\n\n\n\n<p>What if a player leaves the game intentionally or unintentionally? MQTT has a smart feature called &#8220;last will message.&#8221; It&#8217;s like a goodbye note that tells other players someone has left the game. This way, everyone stays in the loop.<\/p>\n\n\n\n<p># Central Management&nbsp;<\/p>\n\n\n\n<p>A central game management connected to the central MQTT broker, written in any kind of language, could be used to observe and control the game and all the players.<\/p>\n\n\n\n<p># Why MQTT?<\/p>\n\n\n\n<p>1. **Real-Time Updates**: It&#8217;s fast and perfect for real-time games.<\/p>\n\n\n\n<p>2. **Reliable**: Even if a player&#8217;s connection is shaky, MQTT makes sure messages get through.<\/p>\n\n\n\n<p>3. **Efficient**: It doesn&#8217;t eat up much data, so players won&#8217;t lag.<\/p>\n\n\n\n<p>4. **Simple**: It&#8217;s not complicated to set up and to use.<\/p>\n\n\n\n<p># Conclusion<\/p>\n\n\n\n<p>Using MQTT in multiplayer games is like having a super-efficient mailman who ensures everyone knows what&#8217;s happening as it happens.<\/p>\n\n\n\n<p>For Unity there is a \u201e<a href=\"https:\/\/assetstore.unity.com\/packages\/slug\/265888\">Unity for MQTT<\/a>\u201c and a \u201c<a href=\"https:\/\/assetstore.unity.com\/packages\/slug\/199115\">GraphQL for Unity Pro<\/a>\u201d asset. Easy to use and usable with all the main build targets, including WebGL!<\/p>\n\n\n\n<p>See the <a href=\"https:\/\/youtu.be\/GyWZ7IUFz-4?si=pUk95P6gtVnA7Ewf\">game demo<\/a> I made with MQTT.. I also integrated data from WinCC Unified in the demo, with the GraphQL for Unity Pro Asset.<\/p>\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=\"MQTT for Gaming?\" width=\"474\" height=\"356\" src=\"https:\/\/www.youtube.com\/embed\/GyWZ7IUFz-4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>You can try it out:<a href=\"https:\/\/server.rocworks.at\/unity\/game\/\" target=\"_blank\" rel=\"noreferrer noopener\"> https:\/\/server.rocworks.at\/unity\/game\/<\/a> (could be already removed when you try to access it)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MQTT for Multiplayer Games? I am not a Game-Developer and I do not know how they create multiplayer internet games. But I know that MQTT can be used for that. Why? # IoT turns to IoP MQTT is used for connecting devices. Think about using MQTT for connecting players. &#8220;Internet of Things&#8221; (IoT) will turn &hellip; <a href=\"https:\/\/www.rocworks.at\/wordpress\/?p=1347\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">MQTT for Gaming?<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52,67],"tags":[48,69,68,54,66,49,64],"class_list":["post-1347","post","type-post","status-publish","format-standard","hentry","category-graphql","category-mqtt","tag-graphql","tag-hivemq","tag-iot","tag-mqtt","tag-siemens","tag-unity","tag-winccunified"],"_links":{"self":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1347"}],"version-history":[{"count":10,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1347\/revisions"}],"predecessor-version":[{"id":1416,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1347\/revisions\/1416"}],"wp:attachment":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}