<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by hackertron on Medium]]></title>
        <description><![CDATA[Stories by hackertron on Medium]]></description>
        <link>https://medium.com/@firefistace153?source=rss-31f8e22923b2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*581M6ZBzyfSU_fNE.</url>
            <title>Stories by hackertron on Medium</title>
            <link>https://medium.com/@firefistace153?source=rss-31f8e22923b2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 15:13:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@firefistace153/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Zero knowledge proofs explained like I am 5 years old]]></title>
            <link>https://firefistace153.medium.com/zero-knowledge-proofs-explained-like-i-am-5-years-old-85be2d0a622f?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/85be2d0a622f</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 16:37:41 GMT</pubDate>
            <atom:updated>2025-02-03T16:37:41.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bg5H3V8rQ8u_2iIQIhR--A.png" /><figcaption>zkp</figcaption></figure><h4>What is zero knowledge proof ?</h4><p>I will skip the jargon, zkp (short form of zero knowledge proofs) are basically</p><ul><li>you want to prove a fact</li><li>you don’t want to share the information</li></ul><p>I will explain with example</p><h4>Scenario1 : You want to enter a club and prove you are 21+</h4><p>Bouncer : How old are you ?</p><p>You: I am 22 years old.</p><p>Bouncer: I don’t trust you, you look way too young. Show me your ID</p><p>You: All right, here you go.</p><p>Now the bouncer knows you are 21+ along with all the other details, like your ID number, address, phone etc. All he needed was proof of age.</p><p>Zero knowledge proofs allows us to solve this issue. You can show a proof that just proves you are 21+ not revealing your DOB or any other info. That’s essentially zkp</p><p><strong>example solution/zkp for scenario1</strong></p><ul><li><strong>Age Range Proof:</strong> Issue a digital credential containing your birth year. The ZKP would prove you possess this credential without revealing the actual birth year. The verifier (bouncer in this case) could then check if the birth year corresponds to being over 21.</li></ul><p><strong>Scenario 2 : Secret tunnel entrance</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fpe43pGkiVayedE97ptGvg.jpeg" /><figcaption>tunnel example</figcaption></figure><p>Bond claims that he knows the code for the secret tunnel entrance but the villains don’t believe it. Bond obviously cannot reveal the code(his knowledge) then everyone will know it but he can prove his claim.(btw this is called argument of knowledge)</p><p>Bond suggests, half of you can wait on the other side of the tunnel and half of you can stay here. Bond can enter the tunnel and exit thus proving he knows the code without revealing it and he can reverse the proof(entering from exit side to exit from entrance) to convince the other half.</p><h4>Proofs proofs proofs….</h4><p>There are typically 2 types of proofs</p><ol><li><strong>Interactive proofs </strong>: scenario2 bond example is interactive proof. If there are new set of people he has to repeat the whole proving process and convince them</li><li><strong>Non-interactive proofs</strong>: scenario1 is non-interactive, since once the age of proof is established, it can be used again and again even with new people.</li></ol><h4>Prove colors are different to a color blind verifier</h4><p>You are in a dungeon and the guard is colorblind. He has a piece of paper which has 2 colors. Guard will only let you pass if you can prove him that you can see the colors but here is the catch. If the guard learns the color he will kill you and be free. Only way to pass is to prove the guard that the page has 2 colors but you can’t tell him the colors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QE9XcWglwKLAM4VKySKa4Q.jpeg" /></figure><p>Since you learnt about zkp, you have an idea. Btw you have a coin too with heads and tails. Can you think of a proof system ??</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KViU8nU1A5zTegTaP3OPJw.jpeg" /></figure><p>You come with a proof system. You give the coin to guard and propose this</p><p>You : I can tell whether you flipped the coin or not based on if you flip the page or not</p><p>guard : explain, I don’t understand</p><p>You : It’s simple, I will turn around and you can do the following</p><ul><li>You toss the coin, if it’s head you will flip the paper</li><li>If it’s tails you will not flip the paper.</li></ul><p>Guard : okay, let’s try it. Turn around and I will follow your protocol</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oEJAEBDfA7hhcVa41Hi-BQ.jpeg" /></figure><p>(you turn around, guard flips the coin and shows you the paper )</p><p>You : hmm, paper is flipped. You got head’s on the coin.</p><p>Guard : I don’t believe you. it’s 50/50 chance. Maybe you got lucky. I don’t trust you.</p><p>You : Okay let’s repeat the process 100 times. You says it’s 50/50, if i keep on guessing right the probability will keep dropping if I am lying. from 1/2 to 1/4 and so on..</p><p>(you both perform this again and again for 100 times)</p><p>You : Now the probability of lucky guess is 7.88860905 x 10^-31. It’s just not possible. I know how to differentiate colors.</p><p>Guard: but but….. raaahh You can pass from the gate.. You won !!</p><h4>Takeaway</h4><p>You see, zero knowledge proofs are not 100% true, you just have to convince/proof that the probability is too low and downright next to impossible.</p><p>I hope that zero knowledge and types of proof are clear to you. Now the question is how to generate proofs. It’s not enough to just prove something, we cannot wait for eternity to prove something. Proofs have to be fast and by fast I mean blazingly fast.</p><p>In the next part I will go in more details(read math) of zkp , how to generate proofs and more on non-interactive proofs a.k.a (NARK : non-interactive argument of knowledge)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85be2d0a622f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Augmented Reality Using Unity’s AR Foundation Framework]]></title>
            <link>https://heartbeat.comet.ml/augmented-reality-using-unitys-ar-foundation-framework-17936ab16576?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/17936ab16576</guid>
            <category><![CDATA[heartbeat]]></category>
            <category><![CDATA[ar-foundation]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Mon, 13 Sep 2021 14:02:02 GMT</pubDate>
            <atom:updated>2021-10-20T16:49:30.702Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 2: Selecting Objects to Spawn and Creating a UI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EwqguSQGyXNC8OzOQoJ1bg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@uniboa?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">UNIBOA</a> on <a href="https://unsplash.com/s/photos/augmented-reality?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In this part of our Unity AR exploration series we will learn how to spawn more than one object in our scene. If you have not read the previous part of this series, I suggest you <a href="https://heartbeat.comet.ml/augmented-reality-using-unitys-ar-foundation-framework-3412a58b5bd6">read</a> it before moving forward.</p><p>First we will make the UI for the app. Our UI will be pretty simple, just a panel with three buttons on it. Each button will spawn a different object and clicking on them again will remove the object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*mpzhes6UIW4z_S_R_Gdjeg.png" /></figure><p>Create a panel gameobject and drag the panel to the bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*XayO4n7nTEjAlkeVoQndIA.png" /></figure><p>Copy the panel values from the image below as we want our panel to scale to screen size. Set anchors to bottom center as shown in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*RiHfcvFSiiU3bmaM07ktoQ.png" /></figure><p>Now right click on the panel and add three buttons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*VCs4XLJrWTBAfGLf2VLW1Q.png" /></figure><p>Change the text of the buttons to “chair,” “couch,” and “table.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*tY1hqWkzD7zbC5osadrnCA.png" /><figcaption>Select text field of button</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*fGyN0_nnZhR6j0o7m5glxg.png" /><figcaption>Change text to chair</figcaption></figure><p>Now we need to add logic to our buttons. Currently if you click on them nothing will happen so we will bind an event to it; “on click do something.” Here we want to spawn an object.</p><h4>Importing Models</h4><p>Go to <a href="https://sketchfab.com/feed">sketchfab.com</a> and search for a “chair,” “couch,” and a “table” model. If you want to use the same models that I used in this model you can download them below.</p><p><a href="https://sketchfab.com/3d-models/office-chair-41973aa1808d4a13b84c24497fc77c63">Chair</a>, c<a href="https://sketchfab.com/3d-models/old-couch-8da7e0d122f544e2862b4e592988e183">ouch</a>, and t<a href="https://sketchfab.com/3d-models/table-1132fa2850a24917892733566bd68e74">able</a></p><p>Import the models in unity by dragging and dropping into the models folder just like how we did in the previous article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*kXGF5Yq4Ek0g_0ZKzhrCJQ.png" /></figure><h4>Creating Prefabs</h4><p>Now drag each model into the hierarchy section as shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*5GN9wh_EtbUoteXeT8vDmw.png" /></figure><p>Next go to your prefabs folder and drag “chair,” “couch,” and “table” gameobjects into the prefab folder. When prompted, click on “original prefab.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bf0xlTAwxouEXQxlYY57pg.png" /></figure><p>Now delete the objects from the hierarchy as we don’t want them to be already present in our scene. We want to spawn them when we click the button. Your hierarchy section should now look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*pkB7PlZOxjVPk51t_qlwAg.png" /></figure><p>Now that everything is ready we can jump into the scripts section.</p><h4>Script</h4><p>Copy the following code into your inputmanager.cs script file. I will explain in detail later, but to give you an idea what we are doing is creating three functions to handle our three buttons and a function which will handle the spawning of objects.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9af68c4489f52761d943bb0c9e109bb5/href">https://medium.com/media/9af68c4489f52761d943bb0c9e109bb5/href</a></iframe><h4>Spawning Objects</h4><p>Select Button and click on “add component” in the inspection panel. If you want you can rename the buttons too ( I have renamed them to Button -&gt; Chair, Button(1) -&gt; Couch and Button(2) -&gt; table).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*pkB7PlZOxjVPk51t_qlwAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*BZoxo02ak_X4EKYzgwxgMw.png" /></figure><p>Drag the Chair prefab and drop it to “AR_object” field. Similarly, drag and drop “AR_Camera” to AR_Camera field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*8rACmM1NqifWPsX7GP_7XQ.png" /></figure><p>Next, click on the small + button. We are going to tell Unity what it should do when the button is clicked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*oDGWPFXS_hXSji_hqN_5PQ.png" /></figure><p>In the None (object) field drag and drop your inputmanager.cs script file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tz_41iwdEiDfw2rFzdYqGQ.png" /></figure><p>Click on No Function and select “InputManager” then select “SpawnButton()” function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*bFkNOaX1pteJRlVe4clfqA.png" /></figure><p>Your Button(Chair) should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*6a3kyWQpMoCHJAiSQ0uigA.png" /><figcaption>Chair button</figcaption></figure><p>Repeat the same process for Couch and Table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*Z1eCJgsW76n6aYiOX6Af5w.png" /><figcaption>Couch</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*tj70m2mQ5M1xZZ6gkz382w.png" /><figcaption>Table</figcaption></figure><p>Now all the setup is complete. Time for the explanation.</p><h4>Connecting the Dots</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MdDkTCuRu7EM0kLgk2pK3Q.png" /></figure><p>When the user clicks on button1(Chair) an onclick event is fired. When that event is fired it calls the spawnbutton function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*od0YLJ4eekMDN3MJo0KkKQ.png" /><figcaption>The spawnbutton function that spawns chair</figcaption></figure><p>The function first checks if the spawned boolean variable is true. If it is true that means the object(chair) is already spawned and we remove it ( you can spawn multiple objects of the same type but we don’t want to clutter the scene).</p><p>If the object(chair) is not spawned we call SpawnObject() function and pass our object(chair) to it. SpawnObject() will spawn the object in our scene.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-nJwr00uyNSi2bk_t5iCg.png" /><figcaption>SpawnObject function</figcaption></figure><p>The same logic applies to the other objects and buttons.</p><p>Now, what if we want to spawn more objects — let’s say 10 or 100? Will we create 100 separate buttons and functions for it?</p><p>Nope, there are better ways to do that. We can have a separate class that handles the data(object) and a manager class that will allow only one object to spawn at a time.</p><p>For this small series, these topics are out of our scope and we want to keep things simple. I will provide resources where you can learn more about bigger scope projects.</p><h4>Build and run</h4><p>Go to File -&gt; Build settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*fXV-ZB3du4132OxqrjqScQ.png" /><figcaption>build settings</figcaption></figure><p>Connect your Android device and enable USB debugging if not enabled already. Now click on build and run.</p><h4>Final Result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*mfFpNkJPi8NiYSIoGFjsBw.gif" /></figure><h4>Now What?</h4><p>I would highly recommend the Unity AR tutorials on the unity.learn website.</p><ul><li><a href="https://learn.unity.com/">Learn game development w/ Unity | Courses &amp; tutorials in game design, VR, AR, &amp; Real-time 3D | Unity Learn</a></li><li><a href="https://learn.unity.com/tutorial/placing-and-manipulating-objects-in-ar">Placing and Manipulating Objects in AR - Unity Learn</a></li></ul><p>If you want to learn more about C# design patterns head over to:</p><p><a href="https://www.patrykgalach.com/2019/05/06/design-patterns-in-unity/">Design Patterns in Unity - Patryk Galach</a></p><p><em>Editor’s Note: </em><a href="https://heartbeat.comet.ml/"><em>Heartbeat</em></a><em> is a contributor-driven online publication and community dedicated to providing premier educational resources for data science, machine learning, and deep learning practitioners. We’re committed to supporting and inspiring developers and engineers from all walks of life.</em></p><p><em>Editorially independent, Heartbeat is sponsored and published by </em><a href="http://comet.ml/?utm_campaign=heartbeat-statement&amp;utm_source=blog&amp;utm_medium=medium"><em>Comet</em></a><em>, an MLOps platform that enables data scientists &amp; ML teams to track, compare, explain, &amp; optimize their experiments. We pay our contributors, and we don’t sell ads.</em></p><p><em>If you’d like to contribute, head on over to our</em><a href="https://heartbeat.fritz.ai/call-for-contributors-october-2018-update-fee7f5b80f3e"><em> call for contributors</em></a><em>. You can also sign up to receive our weekly newsletters (</em><a href="https://www.deeplearningweekly.com/"><em>Deep Learning Weekly</em></a><em> and the </em><a href="https://info.comet.ml/newsletter-signup/"><em>Comet Newsletter</em></a><em>), join us on</em><a href="https://join.slack.com/t/fritz-ai-community/shared_invite/enQtNTY5NDM2MTQwMTgwLWU4ZDEwNTAxYWE2YjIxZDllMTcxMWE4MGFhNDk5Y2QwNTcxYzEyNWZmZWEwMzE4NTFkOWY2NTM0OGQwYjM5Y2U"><em> </em></a><a href="https://join.slack.com/t/cometml/shared_invite/zt-49v4zxxz-qHcTeyrMEzqZc5lQb9hgvw"><em>Slack</em></a><em>, and follow Comet on </em><a href="https://twitter.com/Cometml"><em>Twitter</em></a><em> and </em><a href="https://www.linkedin.com/company/comet-ml/"><em>LinkedIn</em></a><em> for resources, events, and much more that will help you build better ML models, faster.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17936ab16576" width="1" height="1" alt=""><hr><p><a href="https://heartbeat.comet.ml/augmented-reality-using-unitys-ar-foundation-framework-17936ab16576">Augmented Reality Using Unity’s AR Foundation Framework</a> was originally published in <a href="https://heartbeat.comet.ml/">Heartbeat</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Unreal Engine 5 is a BIG DEAL]]></title>
            <link>https://firefistace153.medium.com/why-unreal-engine-5-is-a-big-deal-8e4f058f9c3c?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e4f058f9c3c</guid>
            <category><![CDATA[unreal-engine]]></category>
            <category><![CDATA[epic-games]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[ue5]]></category>
            <category><![CDATA[unreal-engine-4]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Thu, 27 May 2021 18:02:04 GMT</pubDate>
            <atom:updated>2021-05-27T18:02:04.634Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p6HuxsmSxqgqHhAE2sImZQ.png" /></figure><p>Unreal engine 5 alpha build has just been released and we couldn’t be happier. Since the early announcement and demo of Unreal Engine 5 last year everyone was waiting for it.</p><p>People are even saying industry will never be same. It’s the next generation of gaming .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oyt5ZQv_SttcLuxgf-BxoQ.jpeg" /></figure><p>There are plenty of new things in UE5 like metasound , new UI but main two big reasons are</p><ul><li>Lumen</li><li>Nanite</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*AEBppbOypx9QWtnbqMrlbA.png" /></figure><p>Since the dawn of compute graphics developers have tried to achieve the elusive “<strong>real-time global illumination</strong>”. That means getting dynamic bounce light without having to wait hours for a single frame to render</p><p>This is what a scene would look in without Lumen (no global illumination)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RUUXFyApbyeJm8G3LCGZNg.png" /><figcaption>Lumen off</figcaption></figure><p>Same scene with Lumen on (global illumination)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yx_CrPTtsOSQNHlXKaQoVw.png" /><figcaption>Lumen on</figcaption></figure><p>All the light you see in above scene is bounce light. Everything dynamic no light-maps no baking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*ndHNc9ZcJGtdGZmMVmrEtQ.png" /></figure><p>Simply put nanite allows for dynamic level of detail. This means you can have an asset comprises of millions of polygons but it is still performant in game because those polygons dynamically deform lowering the total amount of vertices on a static mesh. This allows for high poly movie asset to be used in game.( Note : it only works for static meshes though)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8mGJMAdaWPD7z1TTAm8tLA.png" /><figcaption>Nanite visualization</figcaption></figure><p>This is not noise. These are triangles each of different color. Most of them so small that they look like noise. Nanite achieve detail down to the pixel.</p><p>Here we are pretty much getting one pixel per triangle. Nanite handles all the dynamic LOD’s(level of details)</p><h3>Get UE5</h3><p>You can get UE5 directly from Unreal Engine website</p><p><a href="https://www.unrealengine.com/en-US/unreal-engine-5">Unreal Engine 5</a></p><p>if you want source code get it directly from Unreal Engine github repo</p><p><a href="https://github.com/EpicGames/UnrealEngine/tree/ue5-early-access">https://github.com/EpicGames/UnrealEngine/tree/ue5-early-access</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e4f058f9c3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Augmented Reality Using Unity’s AR Foundation Framework]]></title>
            <link>https://heartbeat.comet.ml/augmented-reality-using-unitys-ar-foundation-framework-3412a58b5bd6?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/3412a58b5bd6</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[heartbeat]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Tue, 13 Oct 2020 13:45:41 GMT</pubDate>
            <atom:updated>2021-10-07T14:04:15.339Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 1: Detecting planes, placing objects</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bE0CZgitvz0yFSBDaoQDDw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@uniboa?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">UNIBOA</a> on <a href="https://unsplash.com/s/photos/augmented-reality?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In this part of our tutorial series exploring Unity’s AR Foundation framework, we’ll learn how to detect planes and place objects on those planes. We will also learn how to use C# to create scripts and add programmable behavior to our app. If you have not read the <a href="https://heartbeat.fritz.ai/getting-started-with-augmented-reality-using-unitys-ar-foundation-framework-d2752c3e803c?source=your_stories_page-------------------------------------">i</a>ntroduction to this series, I suggest doing so, as this is a continuation from our overview.</p><p><a href="https://heartbeat.comet.ml/getting-started-with-augmented-reality-using-unitys-ar-foundation-framework-d2752c3e803c">Getting Started with Augmented Reality Using Unity’s AR Foundation Framework</a></p><p>To summarize in previous part we did setup and prerequisites to develop AR application. We spawned a cube to test our initial setup. That cube was manually placed and was only there to test things. It’s no longer needed from here onward.</p><p>Start by removing the cube that we added in previous part. We don’t need it anymore, as we were just using that for basic demo purposes. Right click on the cube and select delete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*nyExCbzgH8iCgcg6CbBVTQ.png" /></figure><h3>AR Plane</h3><p>What is an AR plane? An AR plane is basically a plane manager that detects planes (flat surfaces) in the real world scene. A plane is a flat surface represented by a pose, dimensions, and boundary points.</p><p>Examples of features in the environment that can be detected as planes are horizontal tables, floors, countertops, and vertical walls. For our use case ( spawning objects on horizontal planes), we only care about horizontal planes, as we’ll place furniture on them.</p><p>Right click on hierarchy (top left) and select XR → AR Default Plane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*ImoSLHzd7Hwda5CeaOBhRQ.png" /></figure><p>Next, we’ll create a Prefab of our plane. The Prefab asset acts as a template from which you can create new Prefab instances in the Scene. Think of Prefab as a class that holds specific properties, with which you can create as many children from it, all with the same properties.</p><h4>Why do we need a Prefab?</h4><p>When you want to reuse a GameObject configured in a particular way — like a non-player character (NPC), prop, or piece of scenery — in multiple places in your Scene, you should convert it to a Prefab. This is better than simply copying and pasting the GameObject, because the Prefab system allows you to automatically keep all the copies in sync.</p><p>Create a new folder called Prefab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*c4iWkplSgh4Wgq7EtRRo4A.png" /></figure><p>Next, drag the “AR Default Plane” to this Prefab folder. That’s it! Our Prefab has been created. To learn more about Prefabs, head over to Unity’s docs on the subject:</p><p><a href="https://docs.unity3d.com/Manual/Prefabs.html">Prefabs</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*LDZNXy_w04R0oSNVpEdw7Q.gif" /></figure><p>Next, we need to add a Plane Manager. Select “AR Session Origin” and click on the Add Component button. Type “plane” and you will see “AR Plane Manager” component in the search box:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rn6gmth1V9c2Wdg_o56ZYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*_TGa_qzhi8UOVnRzGdJhww.png" /></figure><p>This AR Plane Manager will basically perform all the calculations for plane detection. We don’t have to write algorithms to do that ourselves. Pretty useful stuff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*pKE2s1GKjB-heBIx11MZAg.png" /></figure><p>At the beginning of this article, I mentioned that we only want to detect horizontal planes. So from the Detection Mode parameter, select only horizontal detection. In the “Plane Prefab” slot, drag and drop our “AR Default Plane” prefab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b6A434M2WVreRxnEP73yjg.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*B0W4x-zyHeG11coM4eJkKA.png" /></figure><p>All right—our Plane Detection and Plane Manager components are set up. Since we have a Prefab (AR Default Plane) in our Prefab folder, we can remove it from our hierarchy. We have no need to place it directly in our scene—this is the job of the AR Plane Manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*SR79nzN0ksFs9VjmWKLBtA.png" /></figure><h3>3D Models</h3><p>Now that we have our plane detection set up, we need to tell it what it should do when it detects a plane. For that, we need a script for it to follow (more on that later).</p><p>The idea here, essentially, is to project a ray from our camera to our AR plane, and if that ray hits said plane, we’ll spawn an object.</p><p>To throw the ray (the proper term is raycasting), we need a raycasting component. Select AR Session Origin, then search for and add a “AR Raycast Manager” component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*Ojp9NPHIY1Bh2Ie8unI7tw.png" /></figure><h3>Getting models</h3><p>We need to obtain a few 3D models of furniture to actually spawn. On the web, there are any number of sites like cgtrader, sketchfab , turbosquid etc where you can find some free 3D models for your furniture.</p><p>Make sure to check the license and ensure that it’s free download, and always try to credit the creator. I am downloading one from cgtrader by <a href="https://www.cgtrader.com/nikos95-95">nikos95–95</a>:</p><p><a href="https://www.cgtrader.com/free-3d-models/furniture/sofa/natuzzi-agora">Natuzzi agora | 3D model</a></p><p>Next, we need to create a Models folder, so we can keep our 3D assets clean and organized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*gYV-_JpV9gKOPJeMkzIx5A.png" /></figure><p>Extract the zip and find the FBX file. Drag and drop it in the Models folder you just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*4OJuTs0KHzYf_xlZQAR4Ew.png" /></figure><p>Rename the model to “couch”, or whatever name you’d like, and drop it in the scene to create a Prefab of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jdc_N4zoXx7GXldaCwyxSg.png" /></figure><p>When we’re using these models, we need to make sure their dimensions make sense with respect to real world. Click on your model and open the Inspector tab to check the scaling factor. 1 meter in Unity means 1 meter in the real world, so keep this in mind when you’re using models for these kinds of applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*UO2NyphCAXOs14f0-TmVOg.png" /></figure><p>Next, move the couch Prefab to the Prefabs folder and delete it from the scene. We don’t want to place it manually, but we instead want our Plane Manager to spawn it when it detects a plane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*01JnOkfkLZeWJI9q57FEog.png" /></figure><h3>Spawning Objects</h3><p>Create a Scripts folder and then right-click and create a C# script. Rename it to “InputController”. The idea behind this script is to first detect planes (horizontal planes like floors, table-tops etc) and spawn an object when the user taps on the screen. We will achieve this with script below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35e963021f1ca87cbea52f6cb961ce5d/href">https://medium.com/media/35e963021f1ca87cbea52f6cb961ce5d/href</a></iframe><p>Let’s break this down a bit. First, we need a GameObject, which will store the information about our model. Think of it as a variable that’s storing our model.</p><p>We also need Camera object to manage our camera and a RayCastHit list to store the list of raycast hits, i.e. a list of points where our ray was hit.</p><p>We then check for an Input (we’re using a GetMouseButton, given that we’re on mobile because it’s simple and it works with a simple screen tap). We then check for the position of the mouse (tap on screen) and check to see if the point is in the RayCastHit list or not.</p><p>If it is, then we take its position and rotation to spawn an object there. We’ll see this in action in a moment.</p><p>For now, head back to Unity and create an empty GameObject. I have already created it, which you can see in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*F4yiX-DVLkndtXqof8O-qw.png" /></figure><p>Click on “Add Component” on the Inspector tab and type add an Input Handler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*AfhQfabkxQLEolEJwV7JGw.png" /></figure><p>You will see 3 slots: AR_object, AR_Camera, and RayCast Manager. Drag and drop these from the Hierarchy section. Here, we’re basically telling our script which camera to select, which object to spawn, and which Raycast Manager to use—the variable we defined above in our script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r4OWjLous0gRLrzb7gEkjQ.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*f2ET-Vfgkmtb4K75rJ54_g.png" /></figure><p>Our script is now ready. It has all the information we need it to have. Time to test things out!</p><p>Connect your Android device, and click on File → “Build and Run”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*QRIU2GXpIZpvUkyavvoEUw.png" /></figure><p>Unity will automatically launch your app. Now point the camera at the floor where you’d like to place your 3D model. You’ll see the yellow plane/grid, and if you tap on it, it will spawn the object (the couch, in this case).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*LNvC81p5pk52XROivm0qXw.gif" /></figure><h3>What’s next</h3><p>That’s it for this part of our tutorial series! In the next part, we’ll work more on the UI and also learn how to spawn more than one object in our world/scene. Stay tuned!</p><p>Have some suggestions ? Let’s connect <a href="https://twitter.com/jayssj1"><strong>Twitter</strong></a>, <a href="https://github.com/hackertron"><strong>Github</strong></a>, <a href="https://www.linkedin.com/in/jayaditya-gupta-a56454129/"><strong>LinkedIn</strong></a></p><p><em>Editor’s Note: </em><a href="https://heartbeat.comet.ml/"><em>Heartbeat</em></a><em> is a contributor-driven online publication and community dedicated to providing premier educational resources for data science, machine learning, and deep learning practitioners. We’re committed to supporting and inspiring developers and engineers from all walks of life.</em></p><p><em>Editorially independent, Heartbeat is sponsored and published by </em><a href="http://comet.ml/?utm_campaign=heartbeat-statement&amp;utm_source=blog&amp;utm_medium=medium"><em>Comet</em></a><em>, an MLOps platform that enables data scientists &amp; ML teams to track, compare, explain, &amp; optimize their experiments. We pay our contributors, and we don’t sell ads.</em></p><p><em>If you’d like to contribute, head on over to our</em><a href="https://heartbeat.fritz.ai/call-for-contributors-october-2018-update-fee7f5b80f3e"><em> call for contributors</em></a><em>. You can also sign up to receive our weekly newsletters (</em><a href="https://www.deeplearningweekly.com/"><em>Deep Learning Weekly</em></a><em> and the </em><a href="https://info.comet.ml/newsletter-signup/"><em>Comet Newsletter</em></a><em>), join us on</em><a href="https://join.slack.com/t/fritz-ai-community/shared_invite/enQtNTY5NDM2MTQwMTgwLWU4ZDEwNTAxYWE2YjIxZDllMTcxMWE4MGFhNDk5Y2QwNTcxYzEyNWZmZWEwMzE4NTFkOWY2NTM0OGQwYjM5Y2U"><em> </em></a><a href="https://join.slack.com/t/cometml/shared_invite/zt-49v4zxxz-qHcTeyrMEzqZc5lQb9hgvw"><em>Slack</em></a><em>, and follow Comet on </em><a href="https://twitter.com/Cometml"><em>Twitter</em></a><em> and </em><a href="https://www.linkedin.com/company/comet-ml/"><em>LinkedIn</em></a><em> for resources, events, and much more that will help you build better ML models, faster.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3412a58b5bd6" width="1" height="1" alt=""><hr><p><a href="https://heartbeat.comet.ml/augmented-reality-using-unitys-ar-foundation-framework-3412a58b5bd6">Augmented Reality Using Unity’s AR Foundation Framework</a> was originally published in <a href="https://heartbeat.comet.ml/">Heartbeat</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Augmented Reality Using Unity’s AR Foundation Framework]]></title>
            <link>https://heartbeat.comet.ml/getting-started-with-augmented-reality-using-unitys-ar-foundation-framework-d2752c3e803c?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2752c3e803c</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[heartbeat]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Thu, 17 Sep 2020 13:32:06 GMT</pubDate>
            <atom:updated>2021-09-29T18:24:02.062Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 0: Environment setup and prerequisites</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bE0CZgitvz0yFSBDaoQDDw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@uniboa?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">UNIBOA</a> on <a href="https://unsplash.com/s/photos/augmented-reality?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Have you ever wanted to make your own augmented reality app, but don’t know where to start? Or, are you just interested in AR technology more broadly?</p><p>In this series, we’ll demonstrate how to use Unity’s game engine to make a small AR app that can demonstrate important principles of the technology. To do so, we’ll dive deep in to Unity’s AR Foundation framework.</p><p>AR Foundation allows you to use ARCore from Google and ARKit from Apple at the same time (the primary frameworks for building mobile AR experiences). Think of it as an interface that will use ARCore and ARKit in the background.</p><p>By the end of this series, you’ll have an app similar to IKEA’s AR app:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fcdv0b0nBqPk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dcdv0b0nBqPk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fcdv0b0nBqPk%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4ab0e501e63a2b6cf772313d080b47b/href">https://medium.com/media/c4ab0e501e63a2b6cf772313d080b47b/href</a></iframe><p>We’ll start with the basics: setting up Unity, setting up Unity for Android and iOS, and an overview of how augmented reality works.</p><h3>Augmented Reality</h3><h4><strong>What is AR?</strong></h4><p>Augmented reality (AR) uses computer graphics or video composited on top of a live video feed to augment what a user sees—essentially creating an interaction between real and virtual objects.</p><p>Augmented reality can be used for a wide range of purposes, including in games, for medical training, in retail, design, and more.</p><h4><strong>How it works</strong></h4><p>All these examples listed above (games, design) require understanding the physical world from a camera feed—i.e. the AR system must understand <em>what</em> is in the world and <em>where</em> in the world before adding digital objects to a scene. This is achieved using computer vision. The process itself is complicated and could fill an entire topics on its own, but essentially we use AR frameworks to detect plane , distances, and other key 3D calculations.</p><p><a href="https://heartbeat.comet.ml/combining-artificial-intelligence-and-augmented-reality-in-mobile-apps-e0e0ad2cfddc">Combining artificial intelligence and augmented reality in mobile apps</a></p><h3>Getting Started</h3><p>To get started, download <a href="https://unity3d.com/get-unity/download">Unity</a>. You have to sign-up and accept their license too download. Installation is pretty straightforward—just make sure to check these options so we can work across platforms:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*W0U_Np51Y6Uqfw4P_IBtrA.png" /></figure><p>I am using Unity 2019.4.9f1 (LTS) on a Linux (Kubuntu) machine. You can download the same Unity version OR can install any latest one. The steps are similar regardless of the operating system.</p><p>Create a new project (select 3D project) and name it ARWorld:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*2xAfvI8JqiDcGcln-_p9cA.png" /></figure><h3>Understanding Unity’s Interface</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1fNe9Vhn_fM-8L4nmAf9MA.png" /></figure><p>Here’s a quick look at some of the core pieces of Unity’s primary interface:</p><ul><li><strong>Project</strong>: The Project section holds your project files and structure.</li><li><strong>Console</strong>: The Console is where you can see the logs, errors, and console output.</li><li><strong>Hierarchy</strong>: The Hierarchy is where you can see the game components that are currently in your scene (game-level).</li><li><strong>Scene</strong>: The Scene (a.k.a viewport) is where you can see your game level and how it looks.</li><li><strong>Inspector</strong>: The Inspector is where you can set the properties of your gameobjects (components that you drop in your game/scene).</li></ul><h3>Setting Up Unity</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*XbetkaL75hSB8Ko38bPb-A.gif" /></figure><p>First, we need to setup Unity for the specifics of our project. We’ll start with Android. Following the gif above, go to File → Build Settings and change the platform to Android. Click on switch platforms.</p><p>Next click on Window → Package Manager:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*uIwWaJlY6qXL-EePhN2g3w.png" /></figure><p>Install the following packages: AR Foundation, ARCore (if using Android), and ARKit (if using iOS):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*g0RAEtW44-KN67EE8hlI6w.png" /><figcaption>Installing packages (AR Foundation seen selected here)</figcaption></figure><p>Next, we’ll change our Project Settings (found under the Edit menu). First, go to XR plug-in management and select Android, choosing ARCore. For iOS, it will be ARKit in the iOS section. From here, for clarity, we’ll assume you’re working with Android and ARCore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*6LwCjtgL-p-j6Y8Xkxvnvw.png" /></figure><p>Next go to Player Settings → Other Settings. From here, make sure the Auto Graphics API is set to Android version 7.0 (minimum)—this is the Android version in which ARCore was introduced. Uncheck multi-threaded rendering (it won’t work with AR).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*5Qf0yBlm7ECDEMY6ae211w.png" /></figure><p>Next, head over to the XR section and save these settings. Click on Create, keeping the default name:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*dZpVsPq7Qh6mACtYdc-kww.png" /></figure><h3>Setting Up Our Device</h3><p>In order to test our application and to further develop it, we need to run it on our device. There are certain steps that are needed to allow our device to install our app.</p><p>This can be done by enabling developer settings. Developer settings(access) allows us to do perform certain operations like install app via USB, debugging that are not allowed for normal users.</p><p>This step varies from vendor to vendor, so I suggest look up the information specific for your device. But generally speaking, you need to go into your device settings, find build info, and tap 7 times on the build number or kernel . For more detail, you can look at the Unity docs (Android linked here):</p><p><a href="https://docs.unity3d.com/Manual/android-sdksetup.html">Android environment setup</a></p><p>Once the developer options are enabled, make sure both “Install via USB” and “USB Debugging” are checked:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*iwGsqJ1JTXtVudZLNYXHPQ.jpeg" /></figure><p>Go back to the Unity interface and open up the Build Settings (File → Build Settings). Connect your device and click the refresh button. It should be listed as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*Y58rE9o7iyg0PvqgR6hDgA.png" /></figure><p>With all these prerequisites setup, we now need to test them, just to make sure we’re ready to go. To do this, we’ll create a very small test app.</p><h3>Test App</h3><p>Right-click on the Hierarchy section and choose XR → AR session.</p><p>We also need to add origin point in our app . Origin is (0,0,0) coordinates. Right click on the Hierarchy secition and choose XR → AR session origin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P6J1qM1rvX2v15LsXgTvRQ.png" /></figure><p>The AR Session object provides a lot of built-in setup that our scene needs in order to work as an AR scene. It gives us a way to query the physical world around us, and also a way to manipulate the scale of our virtual world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yXVKYO2ZNuChwJEF5dJdoA.png" /></figure><p>Notice that our AR Session Origin already has a camera—as such, we don’t need the default camera (main camera) anymore. Select it and delete it.</p><p>Next, we’ll set out AR camera as the main camera. Head over to the inspection section and select “Untagged” to main camera. Tags help you identify GameObjects for scripting purposes. They ensure you don’t need to manually add GameObjects to a script’s exposed properties using drag and drop, thereby saving time when you are using the same script code in multiple GameObjects.</p><p>Although this step is not needed but it’s a good practice as recommended by Unity. To learn more about good practices you can refer : <a href="https://docs.unity3d.com/Manual/BestPracticeGuides.html">https://docs.unity3d.com/Manual/BestPracticeGuides.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ICunebSqLQaFr_VrdjDDzw.png" /></figure><p>Next, we’ll create a test object( cube) and place it in our scene. Right click and select 3D Object → Cube.</p><p>Change the coordinates of the Cube, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*Qgs1UAOwCTxjRFCwuWElaA.png" /></figure><p>Next, go to File → Build and Run. It will ask for the filename—you’ll need to provide the application’s apk file (ARWorld.apk).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N-RIofVR1SUlhuFribBHqg.png" /><figcaption>Project building</figcaption></figure><p>Once the build is finished, the app will launch on your device. Try to move your camera a little, and you should see the cube that we created in our scene. With this, we’ve set up our project, hooked it up to Android and ARCore, and implemented our first (very simple) AR object!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*4w5Rm-9RJUSxYP75jlUymA.gif" /></figure><h3>What’s Next</h3><p>In the introduction to this series on augmented reality and Unity’s AR Foundation framework, we learned some basics about AR, Unity’s core interface, how to setup our device, and deploy our very basic test application on Android.</p><p>In the next part of this series, we’ll actually start working on our IKEA clone app. We’ll learn about plane detection and placing objects through user interaction with our app.</p><p>Have some suggestions ? Let’s connect <a href="https://twitter.com/jayssj1"><strong>Twitter</strong></a>, <a href="https://github.com/hackertron"><strong>Github</strong></a>, <a href="https://www.linkedin.com/in/jayaditya-gupta-a56454129/"><strong>LinkedIn</strong></a></p><p><em>Editor’s Note: </em><a href="https://heartbeat.comet.ml/"><em>Heartbeat</em></a><em> is a contributor-driven online publication and community dedicated to providing premier educational resources for data science, machine learning, and deep learning practitioners. We’re committed to supporting and inspiring developers and engineers from all walks of life.</em></p><p><em>Editorially independent, Heartbeat is sponsored and published by </em><a href="http://comet.ml/?utm_campaign=heartbeat-statement&amp;utm_source=blog&amp;utm_medium=medium"><em>Comet</em></a><em>, an MLOps platform that enables data scientists &amp; ML teams to track, compare, explain, &amp; optimize their experiments. We pay our contributors, and we don’t sell ads.</em></p><p><em>If you’d like to contribute, head on over to our</em><a href="https://heartbeat.fritz.ai/call-for-contributors-october-2018-update-fee7f5b80f3e"><em> call for contributors</em></a><em>. You can also sign up to receive our weekly newsletters (</em><a href="https://www.deeplearningweekly.com/"><em>Deep Learning Weekly</em></a><em> and the </em><a href="https://info.comet.ml/newsletter-signup/"><em>Comet Newsletter</em></a><em>), join us on</em><a href="https://join.slack.com/t/fritz-ai-community/shared_invite/enQtNTY5NDM2MTQwMTgwLWU4ZDEwNTAxYWE2YjIxZDllMTcxMWE4MGFhNDk5Y2QwNTcxYzEyNWZmZWEwMzE4NTFkOWY2NTM0OGQwYjM5Y2U"><em> </em></a><a href="https://join.slack.com/t/cometml/shared_invite/zt-49v4zxxz-qHcTeyrMEzqZc5lQb9hgvw"><em>Slack</em></a><em>, and follow Comet on </em><a href="https://twitter.com/Cometml"><em>Twitter</em></a><em> and </em><a href="https://www.linkedin.com/company/comet-ml/"><em>LinkedIn</em></a><em> for resources, events, and much more that will help you build better ML models, faster.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2752c3e803c" width="1" height="1" alt=""><hr><p><a href="https://heartbeat.comet.ml/getting-started-with-augmented-reality-using-unitys-ar-foundation-framework-d2752c3e803c">Getting Started with Augmented Reality Using Unity’s AR Foundation Framework</a> was originally published in <a href="https://heartbeat.comet.ml/">Heartbeat</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a side-scroller mobile game with Unreal Engine 4 (Part 7): Adding Menus and Sound]]></title>
            <link>https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-part-7-adding-menus-and-sound-6fcfaa991a76?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fcfaa991a76</guid>
            <category><![CDATA[unreal-engine-4]]></category>
            <category><![CDATA[unreal-engine]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[heartbeat]]></category>
            <category><![CDATA[mobile-games]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Tue, 05 May 2020 13:15:34 GMT</pubDate>
            <atom:updated>2021-10-15T16:57:34.086Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tclugO8WdtXOsG9Gcjk08g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@linzengxiao?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">zengxiao lin</a> on <a href="https://unsplash.com/s/photos/super-mario?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In the final part of our series (we’ve arrived!) we’ll add some polish to our game. To do this, we’ll refine our level by adding a menu system (main and pause menus), which is a necessary part of any game. We will also add background sound to our game.</p><p>Before proceeding forward, a quick recap. We started by learning Unreal basics—how to navigate and create a HUD (heads up display). We also created some enemy AI and winning and losing mechanisms. We even tested the game on an Android device. These are core components of any mobile side-scroller game. In this final part we’ll polish our game so that it can be presentable.</p><h3>Main Menu</h3><p>Open the content browser and navigate to the maps folder. The idea behind creating a main menu is pretty similar to creating a level/map. If you think about it, a main-menu is also a type of level/map. The function of the menu is to list options and load our gameplay levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ja3r45xXkHLwusvrepSlw.jpeg" /></figure><p>Go to the content browser panel and navigate to the Maps folder (Content-&gt;SideScrollerBp-&gt;Maps). Right click on the Maps folder, click “Level”, and name it “MainMenu”. Open it by pressing Enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*uqtF6rUhYNicLsO-QmiQsg.jpeg" /></figure><p>When you open the level you will see a black screen in viewport (that’s normal). This level is empty it has nothing inside it. That’s exactly what we want for our menu. We only want to display buttons that can perform some action or another.</p><p>Switch over to the Blueprints folder (Content-&gt;SideScrollerBP-&gt;Blueprints) and create a new widget blueprint and name it “Menu”. Double click to open it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YfNg2DsP8kpfUwe-TaONyQ.jpeg" /></figure><p>If you remember from previous articles, we used widget blueprints to display information such as time, coins, and health. We can also create buttons that can perform various actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PuqxzR41bZI8h-X7Ys62rw.jpeg" /></figure><p>Add 2 buttons and 2 text fields on the canvas. You can probably see where this is going…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iIl-ZW7DjYoSIIuQtUUuEg.jpeg" /></figure><p>We’re aiming for a quite simple main menu that has only 2 buttons: “Play” and “Quit”.</p><p>Change the text to “Play” for first button and “Quit” for the second button. Change their properties, as shown below (both buttons should have the same properties, except for their texts). You can change the font to your personal preference, but keep in mind it should not overflow the button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*FmEcjGIFjnRNGXVcEuCOzg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1G6gvlK5NpE2-CUHS34TUg.jpeg" /></figure><p>Highlight the “Play” button and add an “on clicked” property. The “on clicked” property is used to perform an action when a button is clicked. This action can be anything—in our case, we want to open a level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*29S4QwEFl1B0Ha0Q9x5ZfQ.jpeg" /></figure><p>Drag a node from the button and type “open level”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4fcPj8x_J9hvF2-gwXBLcg.jpeg" /></figure><p>Type the level name — “SideScrollerExampleMap”. Hit compile and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*mp1AP3cFkilngLU8_oTKcw.jpeg" /></figure><p>Here, we’re specifying which level well be opened when the “Play” button is clicked—hence the name “SideScrollerExampleMap”. If you go into the Maps folder, you’ll find your level names there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*3gEv5xVcDGImGqsCGDhQsA.jpeg" /></figure><p>You can change the name of the level by pressing F2. (If you change the level/map name make sure to change it in “open level”, too)</p><p>Now click on “Quit” button and select add another “on clicked” event. This time we want to exit our game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x4ro2e7rcPReq45YHngF4w.jpeg" /></figure><p>Bring out the node from the button and type “Quit game”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L7v3MFFvc4jLkogXql7_QA.jpeg" /></figure><p>You’ll notice there’s a dropdown menu when selecting “Quit Game”. We can either quit the game or move it to the background. We don’t want our game to go in the background, mainly because we want to completely exit the game. Another important reason is that games consume lots of device resources. If we don’t exit our game properly, it can waste RAM and battery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*hWh4OYHhLWoXaVofLx3sXA.jpeg" /></figure><p>Compile and save. Close the blueprint.</p><p>Now in the Blueprints dropdown, choose Open Level Blueprint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0SHHCBNWy9RtHnB74isSng.jpeg" /></figure><p>If you’ll remember from previous articles, we must tell our level to display our widget(s). Drag a node from “Event BeginPlay” and type “create widget”. For the class, choose “menu”. Hit compile and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVeBP0B_EbwpnrL6zvSbbw.jpeg" /></figure><p>Explanation: Here, we’re telling our level “When this level loads, create a widget of type menu and display it.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*67LmvhW37bTeqYnyF5duiw.jpeg" /></figure><p>Click on Play button and our level will open up. Pressing the quit button will exit the game. Our main menu is working now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WNRdFZFMaY-fPuAWVFY66g.jpeg" /></figure><p>Next we will create a pause menu that will be triggered when a user presses the back button on Android (back button varies from device to device, but the event is the same, so it’ll work for all Android devices.)</p><p>Go the blueprints folder (Content-&gt;SideScrollerBP-&gt;Blueprints) and create a new widget blueprint:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xCGnL1jLuwxK20azct6L9w.jpeg" /></figure><p>The process will be very similar to how we created our main menu—the only difference is we don’t need to create a new map/level. We’ll add 3 buttons and 3 text fields. Compile and save.</p><p>The buttons are self explanatory, and we’ve already worked with a restart button in a previous article:</p><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-4-571ff417df5e">Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 4)</a></p><p>The “Quit” button will be similar to the main menu variety.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBEU17FGxaKGAAso6YZIwg.jpeg" /></figure><p>Open our level blueprint (SideScrollerExampleMap. Right click on the blueprint and type “android back”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*_ojPyBxs5wCThKHd4lQEBA.jpeg" /></figure><p>Drag a node from the pressed node (see image below) and create a widget. Compile and save.</p><p>Explanation: Whenever an Android back event is fired, we create a widget of type “Pause menu” and display it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZN4adIZ3xWLlbNnZclCoEA.jpeg" /></figure><p>So what we’ve done here is handle the back button event. Whenever a player taps the back button the pause menu will pop up.</p><p>But up until this point, we still haven’t been able pause our game, so we have to add that functionality. We’ll drag out a node from “Add to Viewport” and type “Set Game Paused”(tick the checkbox to pause the game).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MFaGUPc0uVTnQTFJv97mcw.jpeg" /></figure><p>Hit compile and save, and close the level blueprint.</p><p>Open the pause menu blueprint that we created above (Content-&gt;SideScrollerBP-&gt;Blueprints).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xCGnL1jLuwxK20azct6L9w.jpeg" /></figure><p>Add an “on clicked” event for the resume button, just like before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UuMrWZAr8He85uUqqxI12g.jpeg" /></figure><p>If the user presses the resume button, we want to go back into the game and remove the widget—but the question arises, which widget do we remove? We have to tell Unreal which widget to remove (there are many widgets in our game). We do this with a function called “get all widgets of class”. Using this function, we tell Unreal to remove widgets of type “pause menu”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fiHK9JuNwrCuU1scMgNSIw.jpeg" /></figure><p>Once we remove the widget, we need to resume our game. Simply uncheck “Paused”.</p><p>Now the restart button should work similarly to the restart button in the “Game Over” screen that we created in a previous articles. If you need to refresh your memory or want to go into more detail, you can read it here:</p><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-4-571ff417df5e">Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 4)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ArCjCOlFSwndjgYAIVG81Q.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*uBAKE7ARkByp4uKde3i8Tg.jpeg" /></figure><p>The “Quit” button is the same as the one we created for main menu. Just make sure to add an “on clicked” event to the button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*obW37GxHZ_wJlUeK3Rl0Qw.jpeg" /></figure><p>Tell the button to quit the game. Make sure to set it to quit in the dropdown menu below, not the background).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*_9H8_R8p7upE0Q3yXiS3RA.jpeg" /></figure><p>Hit compile and save. To test our pause menu, open the level blueprint and add a key node ‘P’. We’re only doing this to test our pause menu functionality— we don’t have an Android back button on our computer. We could build the project again and test it on the device but the time it takes to build a project isn’t worth it here.</p><p>During your game dev journey, you’ll encounter this scenario many times. Although it’s always necessary to test your application on the intended device, it’s a good practice to first test it on your system (development machine).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*LI4ycm2WI6GhJkCiAKwHsQ.jpeg" /></figure><p>Press the ‘p’ key, and you will see your pause menu. The game will also pause.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fGe5fpjXCpStpSrSGE-bw.jpeg" /></figure><p>Tap each button to make sure everything is working like we intended. We’ve created both pause and main menus! Our game is coming together nicely...</p><h3>Sound</h3><p>But we need one final touch. Some nice background music/sound.</p><p>Here’s a good resource for a wide range of sound assets:</p><p><a href="https://patrickdearteaga.com/arcade-music/">Video Game Music by Patrick de Arteaga</a></p><p>( I downloaded solve_the_puzzle.ogg ) All these sounds are royalty-free, so you can use them in your game without any issues.</p><p>Next, import your new sound asset into the engine. Simply click on the import button and navigate to the folder where you downloaded the sound.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*L3yAX3Qgl5-kKoydP1Nsdw.jpeg" /></figure><p>Open the level blueprint (SideScrollerExampleMap) and right click and type “play sound 2d”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P1ZUjK0udMTWdYRTGmldxg.jpeg" /></figure><p>Select the sound asset we imported.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*0XaRI_7KI1XSSNZ-aWSCxA.jpeg" /></figure><p>Connect the nodes as shown below. We want the sound to play when our level loads (i.e. “Event beginplay”). We’re telling Unreal to first create our HUD (heads up display) and add it to our game whenever the level loads. After that, we play our sound.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LVmZ8A5oAJmGh14n0ptk3w.jpeg" /></figure><p>Save the blueprint and hit the play button. You’ll be able to hear the background music when you begin to play.</p><h3>Bringing it all together</h3><p>We now need to organize our levels and tell Unreal how to package the game, and which level it should load first. This part is fairly simple. We just need to change a few project settings.</p><p>Open Settings -&gt; Project Settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gEucZk2GBusNvl6Qsp8aNQ.jpeg" /></figure><p>Go to Maps &amp; Modes settings and choose Game Default Map. Change it to “MainMenu”. You can see that there are 2 options for the map: “Editor Starter Map” and “Game Default Map”.</p><p>The “Editor Starter Map” is the map that will open by default whenever you open the Unreal editor.</p><p>The “Game Default Map” is the map that will open whenever you actually play the game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x0ZRdnTWPsH9zXW9W15caA.jpeg" /></figure><p>We want our game to open the MainMenu level first, instead of our gameplay level.</p><p>Go ahead and build your project again for Android.</p><p>This time during launch, you’ll see the game’s main menu instead of directly jumping into the game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*gtygSF5pshZ1fy_jRvTImg.gif" /></figure><h3>Conclusion</h3><p>Our game is working and has enough core functionality and polish to call it a complete! And with this, we will conclude this series. In this series we learned about basics of UE4—the blueprint system, assets, textures, basic enemy AI, creating losing and winning mechanisms, importing and using assets from the web, and lastly how to deploy the game on Android.</p><h3><strong>Where to go from here?</strong></h3><p>Glad to see you’ve made it this far. You might be thinking what’s next—what should I learn next, read next, or target? In my opinion, to extend this prototype game from here, it would make sense to try to create your own level from scratch and add new game mechanisms to it. This will serve as a good learning experience and help you build on the skills you’ve learned in this series.</p><p>I also highly recommend subscribing to Unreal Engine’s official YouTube channel, where they do lots of live-streaming to explain engine specifics, provide tutorials, and more:</p><p><a href="https://www.youtube.com/user/UnrealDevelopmentKit">Unreal Engine</a></p><p>You will learn things by doing and experimenting, once you are bit comfortable I highly suggest you to take part in a game jam. Game jam are like hackathons but bit longer(usually a week long). You can find some of them here:</p><p><a href="https://itch.io/jams">Game jams</a></p><p>I wish you luck on your game dev journey :)</p><p>Have some suggestions ? Let’s connect <a href="https://twitter.com/jayssj1"><strong>Twitter</strong></a>, <a href="https://github.com/hackertron"><strong>Github</strong></a>, <a href="https://www.linkedin.com/in/jayaditya-gupta-a56454129/"><strong>LinkedIn</strong></a></p><p><em>Editor’s Note: </em><a href="https://heartbeat.comet.ml/"><em>Heartbeat</em></a><em> is a contributor-driven online publication and community dedicated to providing premier educational resources for data science, machine learning, and deep learning practitioners. We’re committed to supporting and inspiring developers and engineers from all walks of life.</em></p><p><em>Editorially independent, Heartbeat is sponsored and published by </em><a href="http://comet.ml/?utm_campaign=heartbeat-statement&amp;utm_source=blog&amp;utm_medium=medium"><em>Comet</em></a><em>, an MLOps platform that enables data scientists &amp; ML teams to track, compare, explain, &amp; optimize their experiments. We pay our contributors, and we don’t sell ads.</em></p><p><em>If you’d like to contribute, head on over to our</em><a href="https://heartbeat.fritz.ai/call-for-contributors-october-2018-update-fee7f5b80f3e"><em> call for contributors</em></a><em>. You can also sign up to receive our weekly newsletters (</em><a href="https://www.deeplearningweekly.com/"><em>Deep Learning Weekly</em></a><em> and the </em><a href="https://info.comet.ml/newsletter-signup/"><em>Comet Newsletter</em></a><em>), join us on</em><a href="https://join.slack.com/t/fritz-ai-community/shared_invite/enQtNTY5NDM2MTQwMTgwLWU4ZDEwNTAxYWE2YjIxZDllMTcxMWE4MGFhNDk5Y2QwNTcxYzEyNWZmZWEwMzE4NTFkOWY2NTM0OGQwYjM5Y2U"><em> </em></a><a href="https://join.slack.com/t/cometml/shared_invite/zt-49v4zxxz-qHcTeyrMEzqZc5lQb9hgvw"><em>Slack</em></a><em>, and follow Comet on </em><a href="https://twitter.com/Cometml"><em>Twitter</em></a><em> and </em><a href="https://www.linkedin.com/company/comet-ml/"><em>LinkedIn</em></a><em> for resources, events, and much more that will help you build better ML models, faster.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fcfaa991a76" width="1" height="1" alt=""><hr><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-part-7-adding-menus-and-sound-6fcfaa991a76">Creating a side-scroller mobile game with Unreal Engine 4 (Part 7): Adding Menus and Sound</a> was originally published in <a href="https://heartbeat.comet.ml/">Heartbeat</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a side-scroller mobile game with Unreal Engine 4 (Part 6): Deploying and testing on…]]></title>
            <link>https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-part-6-deploying-and-testing-on-38431fda300a?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/38431fda300a</guid>
            <category><![CDATA[unreal-engine]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[heartbeat]]></category>
            <category><![CDATA[android-game-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Fri, 20 Mar 2020 13:07:03 GMT</pubDate>
            <atom:updated>2021-01-12T08:09:01.769Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating a side-scroller mobile game with Unreal Engine 4 (Part 6): Deploying and testing on Android</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tclugO8WdtXOsG9Gcjk08g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@linzengxiao?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">zengxiao lin</a> on <a href="https://unsplash.com/s/photos/super-mario?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In the most recent part of this series, we <a href="https://heartbeat.fritz.ai/creating-a-side-scroller-mobile-game-with-unreal-engine-4-part-5-creating-a-boss-enemy-15d43453a909">created a boss enemy</a>. Our <a href="https://heartbeat.fritz.ai/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-4-571ff417df5e">winning and losing mechanisms</a> are also complete, and we can now display the information on the game screen via our HUD.</p><p>In part 6 (this tutorial), we’ll deploy our game to Android.</p><h3><strong>Prerequisites</strong></h3><p>First, we need to download Android CodeWorks from the link below. In essence, CodeWorks has all the necessary tools (SDK, NDK) needed to build and deploy our game on Android.</p><p><a href="https://developer.nvidia.com/gameworksdownload#?dn=codeworks-for-android-1r8">Download Center</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQ0j6YJj2Rj2GJjo_I0q1Q.jpeg" /><figcaption>CodeWorks — here, choosing Windows 64-bit</figcaption></figure><p>Follow the instructions to install CodeWorks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fqigjef562HgNA9cPlTMpg.jpeg" /></figure><p>Next, we need to enable the developer option on your Android mobile device. Go to your phone settings and look for build number and click 7 times on it. You will unlock the developer options. Inside the developer settings, enable USB debugging.</p><p>Normally developer options are not enabled on an Android device (an average user has no need for them, as they aren’t developing any apps/games for Android). USB debugging will allow us to control our Android device via a USB cable. We can read the error logs, send commands, and even deploy our app via this setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kOaJIV36rWTaeJtHR5qePw.jpeg" /><figcaption>Image from Unreal Engine doc</figcaption></figure><p>Open your project in the Unreal editor and go to “Project Settings”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*FPegdXLwQDI5EbyGwr6NGA.jpeg" /></figure><p>Inside of the Project Settings window, navigate to Platforms &gt; Android. Under APK Packaging, there will be a warning that reads “Project is not configured for the Android platform”. Click the “Configure Now” button to automatically set up your project to write the required platform files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lzGYl4pkGmYb-2IE3YJLuA.jpeg" /></figure><p>Provide the Android package name and change the install location from internal to auto. Package name can be anything as long as it adhere to the naming conventions.</p><p>Package name convention is com.YourCompanyName.Project. So for ex. you can set the package name as : com.AwesomeGames.MyFirstgame. Google has made this guideline to have a unique name for every app/games.</p><p>Leave rest of the settings the same (they’ll work good enough for our purposes). Close the Project Settings page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*1Vz93v14wiYyekTng61FUA.jpeg" /></figure><h3>Configuring the Unreal Editor and PIE for Mobile Previews</h3><p>You can set the Unreal Editor’s Play-In-Editor (PIE) mode to provide a preview of how your game will look in the Mobile renderer. In the Toolbar, click Settings &gt; Preview Rendering Level, and then select one of the available rendering levels for Android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*HlxxnYsvabBi7UqcxWhzaA.jpeg" /></figure><p>Click the dropdown next to the Play button in the Toolbar. Choose one of the available Mobile Preview modes, corresponding to the rendering level you selected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*-ioxE4L1X2m50LJRFqDKvw.jpeg" /></figure><blockquote>NOTE : The editor will now display your game in a way that is visually consistent with your target renderer. Additionally, when you press the PIE button, your game will launch in a standalone window set to a standard mobile aspect ratio and configured to emulate a touchscreen using your mouse. These settings will not affect packaging for mobile devices, but they will ensure that you have an accurate preview when working in the editor.</blockquote><blockquote>Personalization, instant expertise, game changing user experiences — these are just a few of the values machine learning can add to mobile apps. <a href="https://www.fritz.ai/newsletter?utm_campaign=fritzai-newsletter-values2&amp;utm_source=heartbeat">Subscribe to the Fritz AI Newsletter to discover more.</a></blockquote><h3>Launching on an Android Device</h3><p>Connect your Android device via a USB cable. Click on the Launch dropdown menu and select your Android device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*0tLLJAUAiMJG_gVJfzNqtA.jpeg" /></figure><p>While your level/game is being launched on your device, the progress will be displayed in the bottom right-hand corner of the screen, as shown in the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*Gd8blfhKdEPYT8oBHHdQ2A.jpeg" /></figure><p>It can take a while, so you can grab a cup of coffee or stretch your legs while you wait.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tebe-A5aToWYSZIXRoccDQ.jpeg" /></figure><p>When the build process is done, the UE4 editor will deploy the game on your device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*UtRXRHPUKoDI58Dv1QqV2w.gif" /></figure><p>Test the game :) Check if it you are able to move around or not. Check if all the functionalities that we coded are working fine or not.</p><h3>Troubleshooting</h3><p>As with any development project, there can be various reasons a particular build fails generally or fails to deploy to the target device. Always perform basic checks first (i.e. ensure that USB debugging is enabled). Also, make sure your devices is listed in the UE4 editor. If not, download drivers specific for your device.</p><p>Here’s a detailed troubleshooting guide provided by Epic Games :</p><p><a href="https://wiki.unrealengine.com/Mobile_Development_Troubleshooting_Guide#Build_Failing">Mobile Development Troubleshooting Guide</a></p><h3>What’s Next</h3><p>In the next part of this series, we’ll polish our game. As you might have noticed currently there is no pause menu or main menu in the game, and there’s also no functionality to handle Android back/quit button.</p><p>Have some suggestions ? Let’s connect <a href="https://twitter.com/jayssj1"><strong>Twitter</strong></a>, <a href="https://github.com/hackertron"><strong>Github</strong></a>, <a href="https://www.linkedin.com/in/jayaditya-gupta-a56454129/"><strong>LinkedIn</strong></a></p><p><em>Editor’s Note:</em><a href="http://heartbeat.fritz.ai/"><em> </em><strong><em>Heartbeat</em></strong></a><strong><em> </em></strong><em>is a contributor-driven online publication and community dedicated to exploring the emerging intersection of mobile app development and machine learning. We’re committed to supporting and inspiring developers and engineers from all walks of life.</em></p><p><em>Editorially independent, Heartbeat is sponsored and published by</em><a href="http://fritz.ai/"><em> </em><strong><em>Fritz AI</em></strong></a><em>, the machine learning platform that helps developers teach devices to see, hear, sense, and think. We pay our contributors, and we don’t sell ads.</em></p><p><em>If you’d like to contribute, head on over to our</em><a href="https://heartbeat.fritz.ai/call-for-contributors-october-2018-update-fee7f5b80f3e"><em> </em><strong><em>call for contributors</em></strong></a><em>. You can also sign up to receive our weekly newsletters (</em><a href="https://www.deeplearningweekly.com/"><strong><em>Deep Learning Weekly</em></strong></a><em> and the </em><a href="https://www.fritz.ai/newsletter/?utm_campaign=fritzai-newsletter&amp;utm_source=heartbeat-statement"><strong><em>Fritz AI Newsletter</em></strong></a><em>), join us on</em><a href="https://join.slack.com/t/fritz-ai-community/shared_invite/enQtNTY5NDM2MTQwMTgwLWU4ZDEwNTAxYWE2YjIxZDllMTcxMWE4MGFhNDk5Y2QwNTcxYzEyNWZmZWEwMzE4NTFkOWY2NTM0OGQwYjM5Y2U"><em> </em></a><a href="http://fritz.ai/slack"><strong><em>Slack</em></strong></a><em>, and follow Fritz AI on</em><a href="https://twitter.com/fritzlabs"><em> </em><strong><em>Twitter</em></strong></a><em> for all the latest in mobile machine learning.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38431fda300a" width="1" height="1" alt=""><hr><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-part-6-deploying-and-testing-on-38431fda300a">Creating a side-scroller mobile game with Unreal Engine 4 (Part 6): Deploying and testing on…</a> was originally published in <a href="https://heartbeat.comet.ml/">Heartbeat</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a side-scroller mobile game with Unreal Engine 4 (Part 5): Creating a Boss Enemy]]></title>
            <link>https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-part-5-creating-a-boss-enemy-15d43453a909?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/15d43453a909</guid>
            <category><![CDATA[unreal-engine]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[heartbeat]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[ue4]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Tue, 25 Feb 2020 15:28:50 GMT</pubDate>
            <atom:updated>2021-10-07T17:25:52.200Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tclugO8WdtXOsG9Gcjk08g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@linzengxiao?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">zengxiao lin</a> on <a href="https://unsplash.com/s/photos/super-mario?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Welcome back to part 5 of our series exploring how to build a side-scroller mobile game with Unreal Engine 4. If you haven’t yet read part 4, I’d recommend reading it here:</p><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-4-571ff417df5e">Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 4)</a></p><p>In the last part, we integrated our winning and losing mechanisms. Here, we’ll work on creating a boss enemy to make our game a bit more challenging.</p><h3><strong>Creating AI enemy</strong></h3><p>To get started, open up the project in the Unreal editor. Right click on the content browser section and create a new blueprint of type “character” in in Blueprints folder (Content-&gt;SideScrollerBP-&gt;Blueprints).</p><p>Up until now, we’ve only used blueprints of type “Actor”. Whenever we want something stationary or an object in our world we should use Actor. This time we don’t want our object (enemy) to be stationary. We want it to have movement and be controlled too. A character blueprint provides us necessary API and tools to do so. Thus we have used “character” blueprint this time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*1pXFXI9xq8olbug-5l9rmg.jpeg" /></figure><p>Rename it to “EnemyAI” and open it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZxAebCFqgBamTqd9UKhrHQ.jpeg" /></figure><p>Add a static mesh component from the “add component” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*Rss-CQ7nScbsHL79HEMeRQ.jpeg" /></figure><p>Download the “orb.fbx” asset from here:</p><p><a href="https://github.com/hackertron/SideScrollerGame/blob/master/orb.fbx">hackertron/SideScrollerGame</a></p><p>Import it into the Unreal editor under the mesh folder. Whenever you want to use assets, think about whether the asset will fit with your game’s context. I can very well use a tank or a giant robot for the boss enemy, but it will look out of place in this game. This asset looks good enough (by good enough, I mean distinct from our current enemy) and not outside the context of this game scene.</p><p>(Note: When we turn to polishing our game—in future posts—we’ll address these kinds of things/decision more)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVoX08tcE-d4AwWMiHipRg.jpeg" /></figure><p>Add the orb asset to “EnemyAI” via the static mesh” component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wPgy0P3LNQOaB-NxArSjYA.jpeg" /></figure><p>We want our enemy to only collide with our player. To make sure this is the case, we change the collision presets from “BlockAllDynamic” to “OverlapOnlyPawn”.</p><p>You can refer to this previous post on handling collisions:</p><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-2-d94ce0becc86">Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 2)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o1g-oNq7QVNhVn9ajRshGg.jpeg" /></figure><p>Currently, our enemy looks dull, as it has no material. To fix this, set the material to “key_mat”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-O4ZhGAcKc2unO5Xvd_zw.jpeg" /></figure><p>It looks better now :D</p><p>All right…here comes the juicy part of the tutorial. Using the “add component” button, add a “pawn sensing” component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*sQSDohkdbt-eQxvV4oRr6Q.jpeg" /></figure><p>Pawn sensing provides hearing and vision sensory elements to a character. Pawn sensing is one of the basic AI components that Unreal provides to us. There are far more advanced AI tools at our disposal, like behavior trees, AI perception, etc. For our needs, though pawn sensing is enough—it’s a simple component that’s also extremely useful and powerful in creating dynamic character AIs.</p><p>The other components (behavior trees, AI perception) are really advanced but complex, too. We can use them in our case, but it will be unnecessary overhead to us. It’s like using flamethrower to light a candle—surely you can do it but it’s not feasible. A simple matchstick can do that job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*yvFfI_Lx_0W6iU1yIdDLNw.jpeg" /><figcaption>Using powerful tools for trivial tasks.</figcaption></figure><p>Click on compile button to see the pawn sensing properties in the editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iUpDBmg9stsJjR-0JMc9iQ.jpeg" /></figure><p>Whoa! What happened right there? To summarize:</p><ul><li>Green lines are the <strong>vision</strong> property of the pawn sensing component.</li><li>Yellow lines and blue lines represent the <strong>hearing</strong> property of the pawn sensing component.</li></ul><p>We only need a vision property for our EnemyAI. Look at the AI properties in the right panel and change the peripheral vision angle to 180.</p><p>Why 180? I want the AI to have almost same the vision as humans. This value is something I have found to be suitable for our level. There is just one simple rule that you must keep in mind when using the peripheral vision angle—the higher the angle, the bigger the field of vision.</p><p>The sight radius, then, is directly proportional to how far your AI can see.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*2KWhM34zQZ3sxss-zSnzxQ.jpeg" /></figure><p>Change the sight radius to 2000 units. 1 unit equals 1cm, so 2000 units equals 20m. Compile and save. Now click on the “on see pawn” event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*K1mfqX9wr_iXmuXlDHI7sw.jpeg" /></figure><p>Go to event graph section of the blueprint, and you’ll see the “on see pawn” event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7BW81VoZ3q05i5f6uj5h8g.jpeg" /></figure><p>Drag a node from this event and type “cast to SideScrollerCharacter”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*agJRWGsz7b8pFvRdhr4x_A.jpeg" /></figure><p>Why are we casting to SideScrollerCharacter? We want our enemy to move to our player when it senses it (i.e. sees it). For that, we’ll need the location of our player in the world. To access that information, we need to cast to the SideScrollerCharacter. Next, right click and type “AI move to”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*PFsx5qUq25ICRyHfzs867g.jpeg" /></figure><p>and connect the nodes as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YixaAjwaqHCuKFUOUx_9FA.jpeg" /></figure><p>Like I mentioned previously, we want our AI to move to our player when it senses it. That’s why we connected the SideScrollerCharacter to the target actor node.</p><p>There’s one more node that we need to set— pawn. Right click anywhere in empty space and type “self”. Connect self to the pawn node. “Ai MoveTo” needs areference to which pawn should move. Self(reference to self) provides that reference to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yEx1kj24XkeEfGMAfNV8YQ.jpeg" /></figure><p>Hit compile and save. Drop the “EnemyAI” blueprint into the game scene.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7GBI9G03GchkE5uem_1Kow.jpeg" /></figure><p>Hit the play button to test this out. You’ll notice that our EnemyAI isn’t moving at all.</p><p>If you’ll recall, at the beginning of this series, we addressed the need to tell computers everything—and that is true for game engines, too. We’ve told our AI to move to our player when it sees it, but we haven’t told it how to move. Just like we use key combinations to move our player, our AI also needs something similar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*p3FjZS4OKXZRBx-BwZEF_A.jpeg" /></figure><p>From the basic geometry section/modes, search for “nav mesh bounds volume”, and drop it in the game scene. Nav mesh bounds volume basically creates a path for our AI. It tells the AI how to move in the world. Remember your AI will only move inside the “nav mesh bounds volume”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eOxO21W3x2hcNQE0hnBy_Q.jpeg" /></figure><p>Now press the “p” key, and you’ll notice a green floor on the nav mesh. Make sure that “nav mesh bounds volume” is a bit below the floor level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*q8pwDbLZHotHzhOlTSkIAw.jpeg" /></figure><p>Now expand the “nav mesh volume” so that it covers the whole level. To expand, press “r” and expand the volume on all three axes (x, y, and z).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWK0bnfCVsC2aIDMJxfLUA.jpeg" /></figure><p>Keep expanding it until it looks something like below. Essentially, this green area represents where your AI can move on the floor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r6PG9VneeNbvUNfzcfFKXA.jpeg" /></figure><p>Hit the play button to test, and you’ll see that the EnemyAI will chase your player.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*fYeFmtSzi0ttEAvg27VSEQ.gif" /></figure><p>Awesome! But there’s still one key thing missing. Right now, the AI is only chasing—it isn’t doing any damage to our player. Let’s fix that.</p><h3>Damaging the player</h3><p>Open up the EnemyAI blueprint, go to right panel and look for the “on component begin overlap” event. Click on the “+” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*FyUj46Z8Ipz6noKZ3psgDw.jpeg" /></figure><p>From here, it’s pretty similar to how we calculated the damage in previous tutorials. You can refer to that tutorial here:</p><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-2-d94ce0becc86">Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 2)</a></p><p>First, drag a node from “other actor” and cast it to “SideScrollerCharacter”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*Dl3UPxXoGsCDixUioCY9iA.jpeg" /></figure><p>Next, bring out the “get health” and “set health” from the “As side scroller character” node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iX4yoy59q_oDyE9C8YhNUQ.jpeg" /></figure><p>Create a branch node by pressing “Ctrl + B”. Also create an “int-int” , “int &gt; int” node by again right clicking and typing “int-int” and “int &gt; int” respectively. We need to calculate the damage and update the existing health. If the health reaches zero we want the player to die.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*JtuLqVoPrufpxCtMIHvkqQ.jpeg" /></figure><p>From here onward, it’s similar to how we connected nodes for previous enemies. Your final BP should look something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LzA0bKhNLisDvcGnT0hySQ.jpeg" /></figure><p>Change the value of “1” from “int-int” to do more damage to player. I will change it to “10” .</p><p>Compile and save. Hit the play button to see the AI in action. Notice how the various elements we’ve added here are working together:</p><ul><li>Our EnemyAI can move and chase our character.</li><li>Our EnemyAI can deal damage to our player when colliding with our player.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Us2AoKsLHNV4wdReq_pusA.gif" /></figure><h3>Defeating the boss enemy</h3><p>We don’t want our “boss enemy” to be invincible. If you’ve played Mario in the past, I hope you remember how to kill an enemy. You jump on top of it’s head. We’ll create that same mechanism for our “boss enemy”. Open the “EnemyAI” blueprint and add a new “box collision” component. We’ll use an invisible box that can detect collision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*a9c6mQxILAf9CCsiFjsWpw.jpeg" /></figure><p>Next, adjust the box on top of our mesh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XJEhntHS73hSpbZvLyrIGA.jpeg" /></figure><p>The box is currently too big. Adjust it’s dimensions like below so that it just fits the head of our mesh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Th6gZCH5tnSkKzevIwWhoQ.jpeg" /></figure><p>Scroll down the right panel and find the event “on component begin overlap” and click on the “+” icon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*mHIIwDCP8ZSZx3gw5MpDag.jpeg" /></figure><p>Switch to event graph section of blueprint you will see a new node: “on component begin overlap”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*3IduD98zISTToQ6ua_CXhQ.jpeg" /></figure><p>Cast it to “SideScrollerCharacter”—we want to kill our boss only when our player jumps on top of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*Uj1hoAzyDHDMCW2ocOEhxA.jpeg" /></figure><p>Next, right click on empty space and type “destroy”. Connect the nodes like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s8yN3aM5zxhRB9iMXWo5aQ.jpeg" /></figure><p>Compile and save. Hit the play button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*WGNoUvSp9PAuu3XxhDa5ow.gif" /></figure><p>Awesome! we can kill our boss enemy.</p><h3>What’s Next</h3><p>Our “boss enemy” is now complete. In the next part of this series, we’ll finally try to run our game on an Android device. Following that implementation, we’ll explore some ways we can add polish to our game.</p><p>Have some suggestions ? Let’s connect <a href="https://twitter.com/jayssj1"><strong>Twitter</strong></a>, <a href="https://github.com/hackertron"><strong>Github</strong></a>, <a href="https://www.linkedin.com/in/jayaditya-gupta-a56454129/"><strong>LinkedIn</strong></a></p><p><em>Editor’s Note: </em><a href="https://heartbeat.comet.ml/"><em>Heartbeat</em></a><em> is a contributor-driven online publication and community dedicated to providing premier educational resources for data science, machine learning, and deep learning practitioners. We’re committed to supporting and inspiring developers and engineers from all walks of life.</em></p><p><em>Editorially independent, Heartbeat is sponsored and published by </em><a href="http://comet.ml/?utm_campaign=heartbeat-statement&amp;utm_source=blog&amp;utm_medium=medium"><em>Comet</em></a><em>, an MLOps platform that enables data scientists &amp; ML teams to track, compare, explain, &amp; optimize their experiments. We pay our contributors, and we don’t sell ads.</em></p><p><em>If you’d like to contribute, head on over to our</em><a href="https://heartbeat.fritz.ai/call-for-contributors-october-2018-update-fee7f5b80f3e"><em> call for contributors</em></a><em>. You can also sign up to receive our weekly newsletters (</em><a href="https://www.deeplearningweekly.com/"><em>Deep Learning Weekly</em></a><em> and the </em><a href="https://info.comet.ml/newsletter-signup/"><em>Comet Newsletter</em></a><em>), join us on</em><a href="https://join.slack.com/t/fritz-ai-community/shared_invite/enQtNTY5NDM2MTQwMTgwLWU4ZDEwNTAxYWE2YjIxZDllMTcxMWE4MGFhNDk5Y2QwNTcxYzEyNWZmZWEwMzE4NTFkOWY2NTM0OGQwYjM5Y2U"><em> </em></a><a href="https://join.slack.com/t/cometml/shared_invite/zt-49v4zxxz-qHcTeyrMEzqZc5lQb9hgvw"><em>Slack</em></a><em>, and follow Comet on </em><a href="https://twitter.com/Cometml"><em>Twitter</em></a><em> and </em><a href="https://www.linkedin.com/company/comet-ml/"><em>LinkedIn</em></a><em> for resources, events, and much more that will help you build better ML models, faster.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15d43453a909" width="1" height="1" alt=""><hr><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-part-5-creating-a-boss-enemy-15d43453a909">Creating a side-scroller mobile game with Unreal Engine 4 (Part 5): Creating a Boss Enemy</a> was originally published in <a href="https://heartbeat.comet.ml/">Heartbeat</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 4)]]></title>
            <link>https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-4-571ff417df5e?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/571ff417df5e</guid>
            <category><![CDATA[heartbeat]]></category>
            <category><![CDATA[unreal-engine]]></category>
            <category><![CDATA[android-game-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Fri, 14 Feb 2020 15:09:28 GMT</pubDate>
            <atom:updated>2021-01-12T08:09:41.947Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 4)</h3><h4>Implementing winning and losing mechanisms, and end-of-level portal, and more</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vntk-G31UEzKvrjdRcdWkg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@linzengxiao?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">zengxiao lin</a> on <a href="https://unsplash.com/s/photos/super-mario?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Welcome back to part 4 of our series exploring how to build a side-scroller mobile game with Unreal Engine 4. If you haven’t yet read part 3, I’d recommend reading it here:</p><p><a href="https://heartbeat.fritz.ai/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-3-4449df52523c">Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 3)</a></p><p>Last time, we created “winning” and “losing” mechanisms, but we didn’t integrate it with our existing game mechanics. Our game mechanics currently have a timer, an enemy system, and a coin collection system.</p><p>We need to now integrate our “winning” and “losing” mechanism with these existing game mechanics. In this tutorial, we’ll do just that.</p><h3>“Game Over” Widget</h3><p>First, open up the project and head over to the to content browser panel.</p><p>Right click in Blueprints folder, navigate to “User Interface”, and create a new “widget blueprint”. Name it “GameOver”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fbiTBoBmNOV5EsB8" /></figure><p>Open this “GameOver” widget and add a text box to it. Change the text to “GAME OVER” and set its properties as described below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XRZFvrWLvBk-QxsL" /></figure><p>You can set this text to the color of your choice, but I like red for messages, as it catches the player’s attention. Change the font size to 150 and anchor it to center.</p><p>Generally the font type, size, and other small details are dependent upon your own perspective and what kind of feeling you want to provide in the game. For example, red is excellent to show danger. Similarly, size should be based upon how it will look on the screen. We have set 150 for the font size for now, but when we build the project for Android, we might have to adjust it accordingly. Most of the time it’s a process of trial and error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/0*ZDPwNiTDF8RT64YG" /></figure><p>Our “Game Over” screen is now ready. But we still have to show it to the player when appropriate. There are 2 conditions when we want to show it:</p><ol><li>If the player runs out of time</li><li>If player health reaches zero</li></ol><p>Open up “SideScrollerGameMode” and add the following code to the existing code (timer). The logic is simple—when the timer hits zero, show the “Game Over” widget.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/0*aDLjzu0R6HuFS1_Z" /></figure><p>We want our “Game Over” screen to show up when the timer is less than zero. Displaying “Game Over” is similar to displaying our HUD. Now compile and save, hit the play button, and wait for the timer to reach zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S4-F1u2YRoAjqgCa" /></figure><p>There’s still one problem with our “Game Over” screen. We can still play our game, even though we see the text on the screen. Let’s fix that.</p><p>Open “SideScrollerGameMode” again and then right click on empty space and bring up “Get Player Character” and “Get player Controller”. From “Get Player Controller”, bring out a node and type “disable input”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/0*vHnuatxEKOw6CFTM" /></figure><p>Here, we basically are communicating to UE4 that when the timer reaches zero, we want to disable player input. Additionally, we’re asking the system to fetch the controller and determine which player is being controlled by it. We want to disable input for that player.</p><p>Compile and save. Hit play again. Try to move the player—you shouldn’t be able to move because we’ve disabled the input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F9u0RzLWcAWa5ZQA" /></figure><blockquote>Personalization, instant expertise, game changing user experiences — these are just a few of the values machine learning can add to mobile apps. <a href="https://www.fritz.ai/newsletter?utm_campaign=fritzai-newsletter-values2&amp;utm_source=heartbeat">Subscribe to the Fritz AI Newsletter to discover more.</a></blockquote><h3>Restart Button</h3><p>Our “Game Over” screen is almost complete. It’s missing one thing — a restart button.</p><p>Open up the “Game Over” widget and add a “button” and a “text block” on top of the button. Change the text to “Restart”, and set its font size according to your preference, but make sure it fits inside the button’s dimensions. Anchor it to the center like we did for the “Game Over” text. Change the button_22 text to Restart (so it’s easier to identify in future, press F2 to rename it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LmMpLg-ONWQ337ij" /></figure><p>Next, click on the Restart button and scroll down the right-side panel to see its properties (for me it’s view because I already clicked it ) Click on “On clicked”. We are basically creating an action on an event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PsgHP-7fHTiyVvBz" /></figure><p>So when the user clicks on the restart button, we want a particular action to be performed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VgRztq5ylXRltZsk" /></figure><p>Next, right click in event graph section and type “open level”, and in the level field type “SideScrollerExampleMap”. This is the name of our level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/0*pBHoq9TJJXIqeP33" /></figure><p>Where do we find the name of the current level? Simply open the Maps folder, and this should be the only level built so far.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/0*RZ-2JplJh7dEqb0P" /></figure><p>Another way to view the current level is to look in top-left of the Unreal editor. There, you’ll see the level/map on which we’re currently working.</p><p>To test, again compile, save, and hit the play button. Wait for the timer to run out. We now see our restart button—click on it to see it in action (it should restart the level).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SRbO2REb_FflBpH5" /></figure><p>We can replicate this same setup for when a player’s health is less than zero. Don’t worry, we don’t have to repeat much. We just need to add a condition for when health reaches less than zero for our “SideScrollerCharacter”. To do this, we’ll create a custom function, which will be called every time the player’s health is reduced. Name the function “Death”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/0*iSn9xQR83LECSysP" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TxCytymfY-dGmKUY" /></figure><p>What we’ve done here is first get the player’s health and then check to see if it’s less than or equal to zero. If the function returns true, then we show our Game Over screen. Just add the same disable input code like we did before for the “Game Over” screen inside the “SideScrollerGameMode”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/0*_b1_3d7vExa68R6o" /></figure><p>Next, open “EnemyBP” and add this death function at the end. Draw a node from “SideScrollerCharacter” and connect it after “DestroyActor”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eYxhCwzWo9iLQW-t" /></figure><p>Hit compile and save. Hit the play button.</p><blockquote>NOTE : Press Shift + F1 to access your mouse controller. In mobile, we’ll use touch so it won’t matter. We’ll learn more about that later when we package our game for Android.</blockquote><p>With this, our losing mechanism is complete. You might have noticed we repeated some code. In the future, we’ll try to avoid it (for now it’s fine). In programming, it’s generally a bad practice to repeat code. That’s why we created the Death function — it will be used a lot, and it wouldn’t be wise to keep on repeating that same code for this process.</p><h3>“You Win” Widget and Portal</h3><p>Next, we’ll work on integrating the “winning” mechanism. To start, download the new asset (portal) here:</p><p><a href="https://github.com/hackertron/SideScrollerGame/blob/master/torri_toe3d.obj">hackertron/SideScrollerGame</a></p><p>I hope you remember how to import assets. Import it in the Meshes folder. This time, when importing, click the “combine meshes” checkbox (found under the Mesh section — click to expand).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/0*pLkp8G_xQLcnAy3X" /></figure><p>Next, create a new blueprint of type “Actor” in the blueprints folder and name it “PortalBP”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*34y00h8NKPLmHZM6" /></figure><p>Open the “PortalBP” and add “static mesh” to it. Add a torri_toe3D mesh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1ZO7pscLkx_A0U8C" /></figure><p>Next, scale it to the following dimensions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/0*XSXmJPe57txbNBbu" /></figure><p>Next, change the Collision Preset to “OverlapOnlyPawn”:.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*eGdgEd43c9AakjJs" /></figure><p>Now place the “PortalBP” like this in your game scene:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*USm8-Dpl3vUvLwEp" /></figure><p>Compile and save. Hit the play button.</p><p>Awesome! We want our player to pass this portal to win the game when he has the key item. We set that property in “SideScrollerCharacter” in a previous article. We’re going to use it now.</p><p>Open “PortalBP”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Sdk_W-V0M26czJvJ" /></figure><p>Click on “On Component Begin Overlap” in the Events panel. We want to check if the condition “haskey” is true. So we cast the overlap StaticMesh to the “SideScrollerCharacter” then check if “haskey” is True. If it is True, then we’ll show a “win” screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*99DtwGGWKTnZWBKA" /></figure><p>Currently, we haven’t yet created a “win” widget. Let’s create it. Right click on the content browser in the blueprints folder and create a new user interface — &gt; widget blueprint and name it “win”.</p><p>Now, provide the “win” widget to the “PortalBP” like below. Compile and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/0*3P2T7ZxspY4b4lI5" /></figure><p>Next, open the “win” widget and provide it a text block and set its text to “You Win!”. Change the font size to suit your preference but anchor it to the center (like we did for Game Over screen). I structured mine like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Hm4eZFJpANEdboOo" /></figure><p>Now play the game and pass through the gate without the key first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NyyrJ482Das192VW" /></figure><p>You’ll notice that, despite passing the portal, we don’t see the “You Win” message. That’s because we didn’t have the needed key. Now, collect the key and try to pass the portal again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N_0vR-3TKgNurDS5" /></figure><p>Look at that! Now our winning and losing mechanisms are complete and integrated into our side-scroller game. You can also add more enemies and customize the level design.</p><h3>What’s Next</h3><p>In the next part of this series, we’ll add a “Boss enemy” to make the game a bit more challenging. We’ll also do a few things to add some polish to our game.</p><p>Have some suggestions ? Let’s connect <a href="https://twitter.com/jayssj1"><strong>Twitter</strong></a>, <a href="https://github.com/hackertron"><strong>Github</strong></a>, <a href="https://www.linkedin.com/in/jayaditya-gupta-a56454129/"><strong>LinkedIn</strong></a></p><p><em>Editor’s Note:</em><a href="http://heartbeat.fritz.ai/"><em> </em><strong><em>Heartbeat</em></strong></a><strong><em> </em></strong><em>is a contributor-driven online publication and community dedicated to exploring the emerging intersection of mobile app development and machine learning. We’re committed to supporting and inspiring developers and engineers from all walks of life.</em></p><p><em>Editorially independent, Heartbeat is sponsored and published by</em><a href="http://fritz.ai/"><em> </em><strong><em>Fritz AI</em></strong></a><em>, the machine learning platform that helps developers teach devices to see, hear, sense, and think. We pay our contributors, and we don’t sell ads.</em></p><p><em>If you’d like to contribute, head on over to our</em><a href="https://heartbeat.fritz.ai/call-for-contributors-october-2018-update-fee7f5b80f3e"><em> </em><strong><em>call for contributors</em></strong></a><em>. You can also sign up to receive our weekly newsletters (</em><a href="https://www.deeplearningweekly.com/"><strong><em>Deep Learning Weekly</em></strong></a><em> and</em><a href="https://www.fritz.ai/newsletter"><em> </em></a><em>the </em><a href="https://www.fritz.ai/newsletter/?utm_campaign=fritzai-newsletter&amp;utm_source=heartbeat-statement"><strong><em>Fritz AI Newsletter</em></strong></a><em>), join us on</em><a href="https://join.slack.com/t/fritz-ai-community/shared_invite/enQtNTY5NDM2MTQwMTgwLWU4ZDEwNTAxYWE2YjIxZDllMTcxMWE4MGFhNDk5Y2QwNTcxYzEyNWZmZWEwMzE4NTFkOWY2NTM0OGQwYjM5Y2U"><em> </em></a><a href="http://fritz.ai/slack"><strong><em>Slack</em></strong></a><em>, and follow Fritz AI on</em><a href="https://twitter.com/fritzlabs"><em> </em><strong><em>Twitter</em></strong></a><em> for all the latest in mobile machine learning.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=571ff417df5e" width="1" height="1" alt=""><hr><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-4-571ff417df5e">Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 4)</a> was originally published in <a href="https://heartbeat.comet.ml/">Heartbeat</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 3)]]></title>
            <link>https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-3-4449df52523c?source=rss-31f8e22923b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4449df52523c</guid>
            <category><![CDATA[android-game-development]]></category>
            <category><![CDATA[heartbeat]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[gamedev]]></category>
            <category><![CDATA[unreal-engine]]></category>
            <dc:creator><![CDATA[hackertron]]></dc:creator>
            <pubDate>Mon, 27 Jan 2020 15:09:17 GMT</pubDate>
            <atom:updated>2021-10-15T17:04:23.369Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 3)</h3><h4>Creating winning and losing mechanisms</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tclugO8WdtXOsG9Gcjk08g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@linzengxiao?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">zengxiao lin</a> on <a href="https://unsplash.com/s/photos/super-mario?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Welcome back to part 3 of our series exploring how to build a side-scroller mobile game with Unreal Engine 4. If you haven’t yet read parts 1 or 2, I’d recommend reading them here:</p><ul><li><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-752468b0e170">Creating a side-scroller mobile game with Unreal Engine 4-with no prior experience</a></li><li><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-2-d94ce0becc86">Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 2)</a></li></ul><p>In part 3, we’ll create “winning” and “losing” mechanisms. The terms themselves are pretty self-explanatory, but to actually build them takes a bit of context.</p><p>So for the winning mechanism, we’ll create a pickup that’s absolutely necessary to win the game. Think about any old school Mario boss level—how do you defeat bowser? By obtaining the axe. Similarly, we’ll also have a key item that’s needed to win the round.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7kLlQIdxqSj1RJxX" /></figure><p>Let’s first create our key item. Open up your blueprints folder and create a new actor BP (blueprint). Call it “keyBP”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/0*KGDm93xXED3IUHdC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*IiZgtPzY8YdpqTU7" /></figure><p>Open up “keyBP” and add a StaticMesh to it. If you’ll recall, we need a StaticMesh to add our assets.</p><blockquote>A good moment to suggest again that if you haven’t read parts one and two, I’d highly recommend it, as I cover key terms and concepts that won’t be repeated in this tutorial.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*jyGpyRau0ApcU9t-" /></figure><p>Add rotating movement to it. Compile and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/0*b_oQTLqfVcKPQhx5" /></figure><p>Download the keyMesh asset from here:</p><p><a href="https://github.com/hackertron/SideScrollerGame/blob/master/key.rar">hackertron/SideScrollerGame</a></p><p>Import the key into the mesh folder like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BUppbkL-1jo3AS2q" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/0*S-_3slZCnVYRu4cw" /></figure><p>Add the “key_mesh” to keyBP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2lvb6QzfEzKpU8ib" /></figure><p>Change the transformation to the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/0*dTqG5RGK-KEUGtd1" /></figure><p>Compile and save. Create a new folder in root and name it “Materials”. A Material is an asset that can be applied to a mesh to control the visual look of the scene. At a high level, it’s probably easiest to think of a Material as the “paint” that’s applied to an object.</p><h3>Creating Custom Materials</h3><p>Now we’re going to learn something new. Let’s create a custom Material for our Key. Currently it looks pale :p (pun intended). Import “key_diffuse” from the key assets folder.</p><p>This is a bit of a long step, so follow each part of this step exactly, and I’ll explain more later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*vcZj5l9jU2rDIsPY" /></figure><p>Next, right click &gt; material &gt; name it “key_mat”, and open it up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/0*GrOZouoBwTZU086f" /></figure><p>Right click and type “texture sample”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/0*ZB7hB6Ox9-WSYqmb" /></figure><p>In the details section, don’t change anything; just add a “key_diffuse” texture in Material Texture base</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/0*YsSgTlV666aSFrT8" /></figure><p>Next, duplicate the “texture sample” node ( Ctrl + C then Ctrl + v), and then right click and type “multiply”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*HHvjIIpjVj6yIA_M" /></figure><p>Again right click and type “constant” .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/0*XRgzRsesuTaT07si" /></figure><p>Set the constant value to “30”. This value can be anything you want but I experimented and found 30 to be enough to achieve the desired glow effect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/0*USOY-JXiBSjCfrM-" /></figure><p>All right, here’s what we did in the previous steps:</p><ul><li>Obtained the sample texture (key_diffuse). Think of a texture as a skin. Just like our bones (mesh) are covered with skin (texture)</li><li>Next we created a constant value, in this case to make our item glow. How did we apply it? We took a normal texture and multiplied it by our constant and fed that value to both the base color and emissive color key-mats (thus achieving a glow effect). To increase/decrease the glow effect you can change the value of constant.</li><li>Lastly, we need to connect our nodes like this:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cZjtEB05ag5t6SYQ" /></figure><p>Now apply this material to the “key”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*09lgAcVfbkfnc_2I" /></figure><p>Next, let’s add collision to our key item. Change the collision preset for this item to “OverlayOnlyPawn”. This is because we only want our player to collide with it. Once that collision happens, we’ll have an event that can be used to perform various actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/0*nZt6gIAnfOjv13e9" /></figure><p>Scroll down to the Events section, and you’ll see an event named “On component begin overlap” (in my case it’s showing as “view” because I already created it—you’ll see a ‘+’ symbol).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/0*Mcd7yDKIpOWLERK_" /></figure><p>Open up “EventGraph” and also open the “SideScrollerCharacter” BP. We want our player to win only when he has the key. Just like in Mario, where in order to defeat Bowser you must collect the axe.</p><p>How do we keep track of this info? We’ll create a new variable of type boolean in our player. Why boolean? The reason is simple: either the player has the key or does not, and so a boolean logically fits this need.</p><p>Create a new variable in “SideScrollerCharacter” and name it “Haskey”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/0*yE01yBqyVNsrsANZ" /></figure><p>Hit compile and save.</p><p>Switch over to “KeyBP” &gt; EventGraph. We want to modify the “Haskey” variable value when our player collides with the key.</p><p>I hope you remember how we detect collisions and perform operations on our character from the previous parts of this series. We just cast to our character, access its variables, and perform the operations that we want.</p><p>It should look like this. When a player collides with the key, we’ll change the “Haskey” from False to True, which means our player now has the key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vxpXOM_Jfp6gy77B" /></figure><p>Our winning mechanism is intact now. To balance things out and add a bit of a challenge, we now need a losing mechanism. In Mario there are primarily 3 ways to lose/die:</p><ul><li>Fall over cliffs or into lava</li><li>Killed by enemy</li><li>Run out of time before finishing a level</li></ul><p>We already have an enemy system (no final boss yet, though). We don’t have lava or cliff in our game (yet). So for now, we’ll create a time mechanism.</p><p>First, we’ll create a countdown timer. Our player should complete the level within 60 seconds. Follow the steps exactly (explained in more detail below).</p><p>Open “SideScrollerGameMode” and click on “open full blueprintEditor”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VTkT-yOykxWJlS4U" /></figure><p>Create a new variable of type Integer and name it “Timer”. Compile and set its default value to “60”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IXS3YP7Se_Lpj1Go" /></figure><p>Next, right click and type “event tick”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/0*zSjYtU4A_HDDE_vj" /></figure><p>Then type “delay” and hit enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/0*0AE4awUeGtTGXJsk" /></figure><p>I hope you remember how to get and set variable values. Bring out “get timer” and “set timer”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3nbqaL42r9lIDJ3T" /></figure><p>Ok that should do it. Time for some explanation before proceeding further.</p><p>In simple terms, here we created a countdown timer using an “event tick”. What is an event tick ? It’s a simple event that’s called every frame of gameplay and will perform operations connected to it. But event tick is too fast—after all, it’s called every frame of gameplay. E.g. for 60FPS, it will be called 60 times a second.</p><p>To fit our needs, we’re using delay. Delay will limit the functioning for some time—say for a second, or any number of second you specify.</p><p>Now that we have a mechanism in place to call something every frame, and we can control it with delay, we have all the necessary things to create our timer.</p><p><strong>WARNING : </strong>The more things you do in Event Tick, the more likely you are to lower your fps (because you’ll be busy doing performing these functions instead running the game). Event Ticks are very powerful and useful but must be used carefully. There are better ways to create a countdown timer(for e.g. Set timer by event : <a href="https://docs.unrealengine.com/en-US/BlueprintAPI/Utilities/Time/SetTimerbyEvent/index.html">https://docs.unrealengine.com/en-US/BlueprintAPI/Utilities/Time/SetTimerbyEvent/index.html</a> or by Set timer by function name), but to keep this tutorial simple and beginner-friendly we’re taking this approach.</p><p>All that’s left now is to subtract the timer by 1 every second.</p><p>Bring out “int — int” and “int &gt; int” node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/0*34lFWZJDLQdhXbh4" /></figure><p>We need a condition for when the timer hits 0—we don’t want it to go into negative numbers. Bring out a branch by pressing “ctrl + B” . Next, connect the nodes as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mb_sioiD8Ah8jKe3" /></figure><p>To summarize, for every tick, we’re adding a delay of 1 second. We have a condition that states if the timer value is &gt; 0, then we proceed and reduce its value by 1 every second. If we hit 0, then we do nothing, as we don’t want the timer to keep reducing its value below 0.</p><p>Let’s add our timer to our HUD. Open the HUD blueprint, and on the right side add 2 text blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/0*2xJuR89B_G6C6ytb" /></figure><p>Change the text to “Timer: 00”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4f_EUeG9VZijOkyB" /></figure><p>Anchor both of the text blocks to the top right using anchors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/0*KfM26xl4_rfNcMaK" /></figure><p>Next, we’ll bind the “00” text block to a function. Click on create binding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/0*wxUZy-z7rtdUX2OR" /></figure><p>On the left panel, you’ll see a list of all of our functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/0*BK3fl15cdKcuPe4O" /></figure><p>It’s a bit confusing and doesn’t communicate any details about it. As we create more functions, this will become a mess. So let’s change the functions’ names to better reflect what they do.</p><p>For each function, click on its name, press F2, and rename “GetText_0” to “Score”, “GetText_1” to “Health” and finally “GetText_2” to “Timer”. The same general principle will apply to other functions as we add them.</p><p>Displaying the timer is also quite similar to displaying score and health—instead of casting to player, we’ll cast it to Game Mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0zBn2lB84SLj4XO1" /></figure><p>Hit compile and save, and then play the game to test it out!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pGFZ42Pt-gZ7nRIw" /></figure><p>Awesome! We now have winning and losing mechanisms in place, which will allow us to build a much more engaging and challenging experience moving forward. This is the right spot to close out part 3.</p><p>In next part, we’ll actually use both of these mechanisms to expand our game. Currently, we only have mechanisms, but there are no consequences about what will happen if the player grabs the key and wins—of if time runs out and the player loses. We’ll work on that in the next part.</p><p>Have some suggestions ? Let’s connect <a href="https://twitter.com/jayssj1"><strong>Twitter</strong></a>, <a href="https://github.com/hackertron"><strong>Github</strong></a>, <a href="https://www.linkedin.com/in/jayaditya-gupta-a56454129/"><strong>LinkedIn</strong></a></p><p><em>Editor’s Note: </em><a href="https://heartbeat.comet.ml/"><em>Heartbeat</em></a><em> is a contributor-driven online publication and community dedicated to providing premier educational resources for data science, machine learning, and deep learning practitioners. We’re committed to supporting and inspiring developers and engineers from all walks of life.</em></p><p><em>Editorially independent, Heartbeat is sponsored and published by </em><a href="http://comet.ml/?utm_campaign=heartbeat-statement&amp;utm_source=blog&amp;utm_medium=medium"><em>Comet</em></a><em>, an MLOps platform that enables data scientists &amp; ML teams to track, compare, explain, &amp; optimize their experiments. We pay our contributors, and we don’t sell ads.</em></p><p><em>If you’d like to contribute, head on over to our</em><a href="https://heartbeat.fritz.ai/call-for-contributors-october-2018-update-fee7f5b80f3e"><em> call for contributors</em></a><em>. You can also sign up to receive our weekly newsletters (</em><a href="https://www.deeplearningweekly.com/"><em>Deep Learning Weekly</em></a><em> and the </em><a href="https://info.comet.ml/newsletter-signup/"><em>Comet Newsletter</em></a><em>), join us on</em><a href="https://join.slack.com/t/fritz-ai-community/shared_invite/enQtNTY5NDM2MTQwMTgwLWU4ZDEwNTAxYWE2YjIxZDllMTcxMWE4MGFhNDk5Y2QwNTcxYzEyNWZmZWEwMzE4NTFkOWY2NTM0OGQwYjM5Y2U"><em> </em></a><a href="https://join.slack.com/t/cometml/shared_invite/zt-49v4zxxz-qHcTeyrMEzqZc5lQb9hgvw"><em>Slack</em></a><em>, and follow Comet on </em><a href="https://twitter.com/Cometml"><em>Twitter</em></a><em> and </em><a href="https://www.linkedin.com/company/comet-ml/"><em>LinkedIn</em></a><em> for resources, events, and much more that will help you build better ML models, faster.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4449df52523c" width="1" height="1" alt=""><hr><p><a href="https://heartbeat.comet.ml/creating-a-side-scroller-mobile-game-with-unreal-engine-4-with-no-prior-experience-part-3-4449df52523c">Creating a side-scroller mobile game with Unreal Engine 4 — with no prior experience (Part 3)</a> was originally published in <a href="https://heartbeat.comet.ml/">Heartbeat</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>