<?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 Amber Chunn on Medium]]></title>
        <description><![CDATA[Stories by Amber Chunn on Medium]]></description>
        <link>https://medium.com/@amber.codes?source=rss-495b26790550------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*rvxQlvTlYCh_5h_3pFYcQQ.jpeg</url>
            <title>Stories by Amber Chunn on Medium</title>
            <link>https://medium.com/@amber.codes?source=rss-495b26790550------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 22:38:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amber.codes/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[Programming Basics: Arrays]]></title>
            <link>https://medium.com/@amber.codes/programming-basics-arrays-beff172de5ee?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/beff172de5ee</guid>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Fri, 12 Aug 2022 03:03:04 GMT</pubDate>
            <atom:updated>2022-08-12T03:03:04.574Z</atom:updated>
            <content:encoded><![CDATA[<h4>A brief overview of the Array object in C#.</h4><figure><img alt="Photo of shimmery hanging discs" src="https://cdn-images-1.medium.com/max/1024/1*ac7VE6XMl2GsEJxrQeBsyw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jjying?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">JJ Ying</a> on <a href="https://unsplash.com/s/photos/arrays?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Arrays. Every programming language has their version. C# is no different. What exactly is an Array? In simplest terms, an array is a data structure that allows you to store a group of variables. You can use any data type for the variables, as long as all elements inside the array are of the same type.</p><p>“Okay”, you’re thinking, “but why are they so special?” You ask such intelligent questions! Arrays are special for one main reason — elements can be looked up with extreme efficiency. This is because arrays use indexing to give order to the elements in the array. Think of it like any alphabetical list. As long as you know the first letter of the word or item name you’re looking for, you can quickly and easily make your way to the needed information. However, if you only know the second letter of the word, you might as well have to read each word on the list in order to find the tricksy item.</p><p>Now, back to that indexing. As we have now learned, this is the key and the biggest advantage of arrays. Indexing provides ways for us to access various methods of retrieving information from the array with expediency. However, there is one slight caveat that you need to keep in mind when working with arrays. Computers count differently from (most) humans. We like to start counting from the number one. Computers on the other hand, begin counting from zero.</p><p>Why does this make a difference? Think about it, if you want the first item, and you ask the nice Mr. Array to look at item number one, it’s going to give you what you ask for — only it won’t be the first item in the array, it will be the second. Additionally, if you want the last item, and you know that the array has 5 elements, your natural instinct will be to ask for item number five. Do you see the issue? As far as the computer is concerned, there is no number five, as an array with five elements is only indexed up to the number four: array[0, 1, 2, 3, 4] . Forgive me for belaboring the point, but some of the most common errors in programs are indexing errors. It is very easy to miscalculate and have a one-off error. That’s why its imperative to keep zero indexing in mind.</p><p>C# specifically allows for three main types of arrays: Single-dimensional, jagged, and multidimensional. Single dimensional arrays are the most straightforward, as they are an array with primitive data type. A jagged array is an array of arrays. Yep, you can have an array with array data types as elements.</p><pre>// Single-dimensional<br>// Declare data type - Give name - set to a new int array of 8 items</pre><pre>int[] mySingleDimensionArray = new int[8];</pre><pre>// Jagged Array<br>// Declare a single-dimensional int array with int array data<br>// Data must be initialized prior to using<br>// We will initialize the data at declaration</pre><pre>int[][] myJaggedArray = new int[][] {<br>new int[] {4, 8, 10, 12},<br>new int[] {245, 902},<br>new int[] {0, 9, 5, 25},<br>new int[] {77, 83, 76, 80},<br>new int[] {1, 5, 10, 20, 50, 100}<br>};</pre><p>Lastly, we have multidimensional arrays. These can be a bit complicated, but think of it like a table with rows and columns. The first row contains a certain number of arrays acting as columns, then each array stacks below the previous row.</p><figure><img alt="Visualization of a multidimensional array" src="https://cdn-images-1.medium.com/max/1024/1*teSA9uRt75NwL3bFa_0Vdg.jpeg" /><figcaption>2D Array — Graphic courtesy of <a href="https://www.geeksforgeeks.org/">Geek for Geeks</a></figcaption></figure><pre>// Declare a 2D array with data of type string and initialize values</pre><pre>string[,] my2DArray = new string[3, 2] { { &quot;bird&quot;, &quot;fish&quot; }, <br>{ &quot;dog&quot;, &quot;cat&quot; }, { &quot;hamster&quot;, &quot;iguana&quot; } };</pre><figure><img alt="3D array illustration" src="https://cdn-images-1.medium.com/max/531/1*by7XLC4arKETCogj4uNUIg.png" /><figcaption>3D Array — Illustration by <a href="https://www.programming-idioms.org/">Programming Idioms</a></figcaption></figure><pre>// Declare a 3D array with dimensions specified and data initialized</pre><pre>int[,,] my3DArray = new int[4, 3, 4] <br>{ { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } }, <br>{ { 16, 17, 18, 19}, { 20, 21, 22, 23}, { 24, 25, 26, 27}, { 28, 29, 30, 31} },<br>{ { 32, 33, 34, 35}, { 36, 37, 38, 39}, { 40, 41, 42, 43}, { 44, 45, 46, 47} } };</pre><p>If you’re asking yourself why the 3D array only goes up to 47, read paragraphs 3 and 4 above for the answer 🙃.</p><p>I hope this C# array primer was helpful! Feel free to reach out with any questions. Until next time… Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=beff172de5ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity: The Importance of Modular Code Part 2]]></title>
            <link>https://medium.com/@amber.codes/unity-the-importance-of-modular-code-part-2-376526744928?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/376526744928</guid>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Thu, 04 Aug 2022 02:23:51 GMT</pubDate>
            <atom:updated>2022-08-12T00:53:44.267Z</atom:updated>
            <content:encoded><![CDATA[<h4>A game design example of making powerups flexible and DRY.</h4><figure><img alt="Super Mario Bros. Mushroom powerup" src="https://cdn-images-1.medium.com/max/1024/1*8owr-BMQRMnQfagnIhndug.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@geekyshots?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Geeky Shots</a> on <a href="https://unsplash.com/s/photos/power-up?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>This is the second part to a discussion about the importance of keeping your code modular. If you missed part 1, you can <a href="https://medium.com/@amber.codes/drunity-the-importance-of-modular-code-part-1-128354aec700">find it here</a>. Now, as promised, let’s run through an example.</p><h4>Functionality Summary</h4><p>This is a side scroller platform game. The player will move towards the right side of the screen. Items will randomly spawn and move toward the left edge of the screen. When the player collides with an item, the script will go to work and determine the item and ability that needs to be activated.</p><h4>Scripts</h4><ul><li>Player.cs — script that contains a method for each power item’s activation</li><li>SpawnManager.cs — controls the spawning of power items</li><li>ItemPowers.cs — controls movement of power items and triggers appropriate Player object method to trigger</li></ul><h4>Item Legend</h4><ul><li>Starman — grants temporary invincibility</li><li>Fire Flower — enables player to shoot fire balls</li><li>1 up mushroom — awards an extra life to the player</li><li>Regular mushroom — gives player extra strength</li></ul><h3>Process Overview</h3><ol><li>Create a ItemPowers.cs script.</li><li>Setup your Start() and Update() methods.</li><li>Add the powerups GameObject[] to SpawnManager.cs .</li><li>Create a OnTriggerEnter2D (or the 3D equivalent).</li></ol><h4><strong>Step 1</strong></h4><ol><li>Create a new C# script called ItemPowers.cs .</li><li>Attach to each item prefab.</li><li>In the Inspector pane, adjust the powerID to the appropriate value.</li></ol><figure><img alt="FireFlower Inspector pane" src="https://cdn-images-1.medium.com/max/710/1*N-dkZkw7F9sVtZim40Xe2A.png" /><figcaption>Step 1, number 3: Inspector window of the FirePower prefab. Note the powerID.</figcaption></figure><pre>using System.Collections.Generic;<br>using System.Collections;<br>using UnityEngine;</pre><pre>public class ItemPowers : MonoBehaviour {<br> private int _powerID = 0;<br> private Player _player;</pre><pre> void Start () {}<br> void Update() {}<br><br>}</pre><h4><strong>Step 2</strong></h4><ol><li>Inside the Start() method of ItemPowers.cs , add a reference to the Player object.</li><li>Inside the Update() method, add movement instructions for spawned powerups. Here, the powerups left and self-destruct when they reach the end of the screen.</li></ol><pre><em>void</em> Start () {<br>  _player <strong>=</strong> GameObject<strong>.</strong>Find(“Player”)<strong>.</strong>GetComponent&lt;Player&gt;();<br>}</pre><pre><em>void</em> Update() {<br><em>// Move power item left at constant speed<br>  </em>transform<strong>.</strong>Translate(Vector3<strong>.</strong><em>left</em> <strong>*</strong> _speed <strong>*</strong> Time<strong>.</strong><em>deltaTime</em>);<br>}</pre><h4><strong>Step 3</strong></h4><ol><li>Inside of SpawnManager.cs add a powerups GameObject[] variable.</li><li>To spawn power items, you will need a coroutine in your SpawnManager. The spawn functionality is out of scope for this tutorial, but I will add an example of one below for reference. If you need a refresher on coroutines, I wrote one <a href="https://medium.com/@amber.codes/unity-basics-coroutines-5d59234b298c">previously</a>.</li><li>Inside of Unity, on the SpawnManager object’s SpawnManager script (inside of the Hierarchy pane), assign each power prefab to the powerups GameObject array.</li><li>Verify that the Element number for each prefab is the same as the powerID given to each prefab in step 1.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*d702IlZMTbvhmYEwMn71nQ.png" /><figcaption>Step 4, numbers 3 &amp; 4: Inspector window of the SpawnManager object, SpanManager Script component. Note Element numbers.</figcaption></figure><pre>// Add Power Items GameObject[] (see item 1 above)<br>[SerializeField]<br><em>private</em> GameObject[] _powerups;</pre><pre>// Powerup Spawn Coroutine (see point 2 above)<br>IEnumerator PowerupSpawnRoutine() {<br> <strong>yield</strong> <strong>return</strong> <strong>new</strong> WaitForSeconds(_spawnDelay);<br> <br><strong>while</strong> (_stopSpawning <strong>==</strong> false) {<br>  Vector3 posToSpawn <strong>=</strong> <strong>new</strong> Vector3(Random<strong>.</strong>Range(<strong>-</strong>7f, 7f), 7, 0);<br>  <em>int</em> randomPowerup <strong>=</strong> Random<strong>.</strong>Range(0, 3);</pre><pre>  Instantiate(<em>_powerups</em>[randomPowerup], <strong>new</strong> Vector3   (Random<strong>.</strong>Range(<strong>-</strong>7f, 7f), 7, 0), Quaternion<strong>.</strong><em>identity</em>);</pre><pre><strong> yield</strong> <strong>return</strong> <strong>new</strong> WaitForSeconds (Random<strong>.</strong><em>Range</em> (3, 8));<br> <br> }<br>}</pre><h4><strong>Step 4</strong></h4><ol><li>Inside your ItemPowers.cs script, create a OnTriggerEnter2D() method.</li><li>We want to detect if the object colliding has the tag of “Player”. If it is the Player object, then we want to grab the object.</li><li>Next, before we proceed with triggering the correct method, we check to make sure there is indeed a Player object, as is best practice.</li><li>Finally, we check the _powerID and trigger the appropriate method inside the Player object.</li></ol><pre><em>private</em> <em>void</em> OnTriggerEnter2D(Collider2D <strong>other</strong>) {</pre><pre><em>// If the Player object collides with the power item<br></em><strong>if</strong> (other<strong>.</strong><em>tag</em> <strong>==</strong> &quot;Player&quot;) {</pre><pre><em>// Grab reference to player object<br></em>Player player <strong>=</strong> other<strong>.</strong><em>transform</em><strong>.</strong>GetComponent&lt;Player&gt;();</pre><pre>// Switch statement checks each _powerID<br>// If the _powerID is equal to the power item ID<br>// Call corresponding method on the player object</pre><pre><strong>if</strong> (player <strong>!=</strong> null) {<br> <strong>switch</strong> (_powerID) {<br>  <strong>case</strong> 0:<br>   player<strong>.</strong>bigMushroom();<br>   <strong>break</strong>;<br>  <strong>case</strong> 1:<br>   player<strong>.</strong>starmanActive();<br>   <strong>break</strong>;<br>  <strong>case</strong> 2:<br>   player<strong>.</strong>fireFlowerActive();<br>   <strong>break</strong>;<br>  default:<br>   player<strong>.</strong>oneUpMushroom();<br>   <strong>break</strong>;<br> }<br>}</pre><pre><em>// If player never collides with power item destroy power item<br> </em>Destroy(<em>this</em><strong>.</strong><em>gameObject</em>);</pre><pre>}}</pre><p>On the face of it, it may not seem like that big of an improvement, but keeping modularity and the DRY principle in mind as you program your game (or any other software) will make you a better developer. It will make your code easier to understand, easier to test, and more expandable. Finally, as mentioned at the start, modularity makes a huge difference in the performance of our game — especially as your projects grow in size and scope.</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=376526744928" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity: The Importance of Modular Code Part 1]]></title>
            <link>https://medium.com/@amber.codes/drunity-the-importance-of-modular-code-part-1-128354aec700?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/128354aec700</guid>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Wed, 03 Aug 2022 01:38:22 GMT</pubDate>
            <atom:updated>2022-08-03T01:38:38.239Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why do we want to limit repeated code?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xISd1fekf-jQXXlf6gRO4w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@unarchive?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jeremy Bezanger</a> on <a href="https://unsplash.com/s/photos/dry-code?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>When programmers here someone says the word “dry”, we aren’t looking for a towel. For t he uninitiated, “DRY” is perhaps the most quoted acronym in software engineering — and for good reason. If you find yourself repeating the same functionality, you’re probably doing it wrong. There is almost certainly a more efficient option that will save you time, space, or even both.</p><p>The ability to optimize your game code so that it doesn’t take up any more space than need be and doesn’t suck up all the client’s resources is one of the most important considerations during the production process. Freeing up the space and memory so that you can prioritize the player’s experience is paramount. One of the primary enhancements you can introduce to accomplish this is modular code.</p><p>What do I mean by <em>modular</em> code? In general, modular code extracts common (read: repeated) code and turns it into a single function (sometimes called a module) that can then account for the different uses of the functionality. That’s a lot of words. I think a more detailed tutorial is called for.</p><p>For our endeavor, I’m going to take inspiration from a very familiar game in hopes that it will help simplify the concept. We are going to create a modular function that controls the behavior of the power items (or powerups, if you prefer) for the classic NES masterpiece Super Mario Bros (abbreviated as SMB). If you need a trip back in time, <a href="https://www.mariowiki.com/Super_Mario_Bros.#Items">MarioWiki</a> has you covered.</p><p>I do have one caveat to mention. I am only concerned with the <em>items</em> from SMB — not the overall gameplay. For example, in the context of SMB, the items would normally pop up from the bricks and/or golden boxes throughout the game. In our example, we are not concerned with how the items spawn. We only need to know that each item has a unique power and we will be controlling that power with our function.</p><p>Like a horrible cliffhanger, I’m going to leave it there. I won’t make you wait until next season for the continuation though. See ya tomorrow!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=128354aec700" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Design: Balancing Timing in Games]]></title>
            <link>https://medium.com/@amber.codes/game-design-balancing-timing-in-games-7a2b0ce03c5f?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a2b0ce03c5f</guid>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Sat, 30 Jul 2022 01:56:44 GMT</pubDate>
            <atom:updated>2022-07-30T01:56:44.077Z</atom:updated>
            <content:encoded><![CDATA[<h4>A thoughtful discussion of how to balance powerups in games.</h4><figure><img alt="PacMan™ Game Over Screen" src="https://cdn-images-1.medium.com/max/1024/1*H38itVeHznr9PhLe27of-w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@sigmund?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Sigmund</a> on <a href="https://unsplash.com/s/photos/video-game?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Remember when you figured out that PacMan® had a pattern to it? I don’t know about you, but my kid self thought I was so smart. I was then able to create my own pattern to escape the ghosts and eat all the pellets. Ah, the good ‘ol days. Then there were those special glowing pellets that made you invincible. However, that power only lasted for a brief period of time. Which makes me wonder, how did they decide how long they would last?</p><p>I’m currently working on a 2D arcade shooter game and, like in many classic games of the genre, I’m including some special powers to help the player along in their journey to Space Glory. You know, that moment you see your three letter gamer tag emblazoned at the top of the leaderboard, so all who play the game will bow to your greatness! Ahem, my apologies. I got a bit carried away there. Moving on.</p><p>A game designer asks many questions and makes many choices that affect how players enjoy the experience, how the game is balanced, and many other factors of the game. All of which should be given special care and attention. Along with power ups, my game has enemies and laser fire which the player must be aware of as they move around the screen. To create this environment, there are a few different timings I had to consider. How fast should the player be able to fire? How fast should the enemies fall? How often and at what speed should the power ups fall? And more.</p><p>When pondering these timings I specifically took them all into account as I kept the big picture in mind — the player’s experience. If I chose to have the enemies fall at a rate of 5f and then had the power ups fall at a rate of 1f, would that result in a fair distribution of the bonus power? Or would it result in just more clutter because the player wouldn’t be able to grab a power up in the crowd? You don’t want to frustrate the player by giving a pointless bonus.</p><figure><img alt="Image of an arcade shooter game with a ship and powerup" src="https://cdn-images-1.medium.com/max/1024/1*qb2QdpnL_TnAP0phlCy57Q.png" /><figcaption>Untitled 2D Arcade Shooter</figcaption></figure><p>I divided my decisions into two main groups. Anything moving toward the player — this would be enemies, lasers, and the power ups icons. The second group were things that give the player power over the normal rules; the power ups themselves. On the opposite side, you don’t want create boring and predictable interactions for the player. For instance, having items fall in a predictable pattern that provides an easy path to victory (looking at you PacMan®). So then, what did I decide, and more importantly, why?</p><p>We want the player to be able to predict some things, so that they can plan a strategy. This allows the player to feel efficacious and gives them a puzzle to solve. My task was then to choose if the player controlled items would be persistent, or would the things flying at the player be the constant. Through this process, I came to understand that if something is under the player’s control, that item should be predictable. Why? Well, again, we want them to be able to plan and scheme their way to victory. That means, they would need to know how the things under their control behave. It wouldn’t be fair to constantly change the behavior of those items, as they wouldn’t be able to create a strategy around that type of system.</p><p>Once I explored all options and decision trees, I decided that the most equitable choice would be to randomize the location and timing of both the enemies and power ups. At the same time, I would provide consistency to the length of time a power up is active and the rate of fire for the player’s lasers. This created a well balanced experience that was challenging, but not impossible. It gave the player the ability to plan moves and analyze what power ups were worth grabbing, given the state of the game. Finally, regarding actual timing, I decided that the power ups would be active at the same rate as the enemies descent. Practically, this provided the player with at least 2 opportunities to gain the power up’s effect. I also allowed for the player to have multiple powers active at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRU5xW2OmagYO2xShbeQfQ.png" /><figcaption>Different Powerup Choices in Untitled 2D Arcade Shooter</figcaption></figure><p>I do have one caveat to all of my choices. Along the way, I kept <em>my</em> overall game design goals in mind. Maybe you want to make a shooter with only one near-impossible path to victory. Or, maybe you want to make a game that feels like a nice relaxing lazy river ride. The point I’m trying to make is to make <em>your </em>game. Keep your decisions focused on achieving your overall goals. Do what makes sense for your characters and the game environments. Make everything congruent with <em>your </em>vision.</p><p>I hope this peek into my design process provided some food for thought when you make your next game. Be fair to your players. At the same time, make sure the challenges they face will provide them a sense of accomplishment and pride when they overcome them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a2b0ce03c5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity: Introduction to Animating Sprites]]></title>
            <link>https://medium.com/@amber.codes/unity-introduction-to-animating-sprites-4c0dff3ecc22?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c0dff3ecc22</guid>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Thu, 28 Jul 2022 14:27:46 GMT</pubDate>
            <atom:updated>2022-07-28T14:27:46.006Z</atom:updated>
            <content:encoded><![CDATA[<h4>A gentle introduction to using the Unity animation system.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ojr_LK0D0msAjdD9V4o3oA.gif" /><figcaption>Jill has had too much coffee today</figcaption></figure><p>Animations are super important to help make your games feel immersive and engaging. Movement grabs attention, focuses attention, and makes interactions exciting. Unity makes creating animations simple and quick. Enjoy this beginner’s guide to animating sprites in Unity.</p><p><strong>Preparation</strong></p><ol><li>Be sure you’ve added your sliced sprites to your project folder</li><li>Add the first sprite for your sequence to your hierarchy</li></ol><p><strong>Creation</strong></p><ol><li>Open (or switch to) the Animation pane: Window &gt; Animation &gt; Animation</li><li>Select the create button</li><li>Give your animation a name and tap save (*<em>To keep organized, I recommend making an Animation folder inside your Assets folder</em>)</li><li>Select object in hierarchy and then click the record button inside the Animation pane</li><li>Select the first sprite for the animation, hold down shift, and click the last sprite. This will select your entire animation sequence.</li><li>Drag the selection to the dope sheet (<em>*The dope sheet allows us to create keyframe animations)</em></li><li>Click the record button again to stop recording your animation</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v6QmSm6oHv_bYd9xTQGH8A.gif" /><figcaption>Animating sprites in Unity</figcaption></figure><p>Unity will have added an animation controller alongside your new animation wherever you saved your animation in Step 3 above. The animation controller is what actually controls the logic for playing the animations. The last item I’d like to point out is that animations are automatically set to loop by default. You can modify this by double clicking the controller from the Animator pane (Window &gt; Animation &gt; Animator). This will bring up some options inside of the Inspector window. If you want to turn off looping, uncheck the Loop Time option.</p><figure><img alt="Animator panel inside Unity" src="https://cdn-images-1.medium.com/max/1024/1*XgjI6uSNpPZWmV7i-B9PbA.png" /><figcaption>Unity Animator panel</figcaption></figure><p>Congratulations on your new animation! Now you can click play to see your new creation <em>movin’ and groovin’</em>. I’m <em>loving</em> my over-caffeinated zombie creeping in the graveyard.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c0dff3ecc22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Design Diary: When Does it Feel Like a Game?]]></title>
            <link>https://medium.com/@amber.codes/game-design-diary-when-does-it-feel-like-a-game-98601a82660?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/98601a82660</guid>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Thu, 28 Jul 2022 00:38:54 GMT</pubDate>
            <atom:updated>2022-07-28T00:38:54.964Z</atom:updated>
            <content:encoded><![CDATA[<h4>A perspective on making games.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWykfbJQAWqJJnfolMpsAQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@ravipalwe?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ravi Palwe</a> on <a href="https://unsplash.com/s/photos/nes?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I remember vividly the moment I wanted to become a programmer. I was in the first day of an elective class I took on a whim because I needed another credit to keep my financial aid. The instructor was teaching about HTML and I was taking notes. After the lecture, it was time to put what we learned into practice using the lab’s computers. I made the canonical first page and when I opened up the page inside of Netscape (*rip), there it was in all it’s glory — “Hello, World!”.</p><p>When deciding what area of programming I wanted to focus on, my first thought was video games. It was only natural for that to pop into my mind first as I’ve been playing video games since I was in kindergarten. Even when I wasn’t playing games, I was contemplating how to beat a level, reading about next month’s releases, and/or considering what I would change about a particular part of a game. However, life happens and to quote one of the all-time most loved lyrics, “You don’t always get what you want…”. I was still able to program and I found a love for UI/UX engineering, but I would still find my mind thinking about making games. Well, as the saying goes, when one door closes… Fast forward to today and — “Look at me, Ma!”, I’m building video games!</p><p>As exciting as actually living my dream is, there are many steps along the path of developing a game. During the early stages along that path, it often doesn’t <em>really</em> feel like you’re making a game. Prototyping looks more like you’re trying to make a math tutorial for geometry. When writing scripts to bring objects to life, it doesn’t feel much different than any other type of programming. It’s kinda like making a cake — it’s pretty boring until you get to lick the spoon. You’ve gotten a taste and you’re now excited for a slice of the baked frosted cake.</p><p>Then, there is a moment when you realize you’ve legitimately been making a game the whole time. For me, this tends to happen once the artwork replaces the prototype shapes. You can now see your player — not a square — moving through the level, defeating an enemy, and grabbing items. Pride and accomplishment begin to creep in, and you get that rush you need to keep building.</p><p>As a maker of games, you embark on a marathon that few people have the opportunity to run. As with any work, however, there are parts that are hard to get through, dull, or otherwise arduous. Sometimes you just need to get to that next mile marker for an adrenaline boost. Then, before you know it, you’ve crossed that finish line.</p><p>Where is the point when you begin to feel that you’re <em>really</em> making a game?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98601a82660" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prototyping Naked]]></title>
            <link>https://medium.com/@amber.codes/prototyping-naked-a3813a0c1a70?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3813a0c1a70</guid>
            <category><![CDATA[gaming]]></category>
            <category><![CDATA[prototyping]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[gamedev]]></category>
            <category><![CDATA[game-design]]></category>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Tue, 26 Jul 2022 19:34:22 GMT</pubDate>
            <atom:updated>2022-07-26T19:35:52.495Z</atom:updated>
            <content:encoded><![CDATA[<h4>A cautionary tale.</h4><figure><img alt="Orange painted blue, cut in half" src="https://cdn-images-1.medium.com/max/1024/1*h2AAZXX2dpxreEjimAHVGA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@davisuko?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">davisuko</a> on <a href="https://unsplash.com/s/photos/painting?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Imagine an artist has won a contest. This contest is the largest, most prestigious art contest in the world. It would be natural to be curious as to what makes this contest so renowned. Every two years, the contest brings together artists from all around the world to a location which rotates each gathering. Each round in the fortnight-long gauntlet pits contestants against each other with the top 3 advancing to the next rounds. For each group in the round, a different medium is highlighted. The final round sees the crème de la crème vying for the chance for the top prize — a commissioned artwork of the home country’s leader in the artists chosen medium. Of course, the winners and top participants gain much from participating besides the prize they are awarded, but this lengthly metaphor is not why we’re here.</p><p>Now, let’s think about the winning artist’s commission. The artist is greeted, perhaps with some pomp and circumstance, and then comes the time for them to get to work. They are a painter, so they set up their easel, pull out their paint and begin painting. Does that sound correct? No, right? Even if you don’t know anything about painting, you can reason that the artist would need to position the subject, set the lighting to their preference, and/or establish their composition — at the bare minimum. Any able artist would conduct a great deal more preparation for such a prominent piece.</p><p>Much like producing an artwork takes thought and preparation, bringing a gaming experience to life needs to begin with the same amount of care. I feel that there are two main advantages to this type of prototyping. First, you will not be tempted to start with the details at the expense of gameplay. Second, the best use of time and money is to nail the function in order to show that the idea you’re so excited about is worth investment — both personally and potentially from outside sources. Let’s examine each of these briefly.</p><p>Rapid prototyping is the most efficient and effective way to proof a game idea. There are many benefits to prototyping with primitive objects instead of using game art itself. I feel that the most important benefit is that you can stay focused on the task at hand — ensuring that the core gameplay is fun, works well, and is satisfying for the player. If the gameplay isn’t compelling, it won’t be a successful game.</p><figure><img alt="3D Geometric objects in Unity" src="https://cdn-images-1.medium.com/max/1024/1*-_KsufR3_i9ZlTnoD1-Qug.png" /><figcaption>Primitive Objects in Unity</figcaption></figure><p>If you can’t captivate your player, making them want to spend time in the world, accomplish the task, or solve that cool puzzle, the game experience needs to change or it won’t be worth building. This is another crucial reason to make use of asset-less prototyping. In oder to become an engaging experience, you (and your team) will be iterating or even scrapping some of the initial ideas and concepts constantly. This needs to be able to be done, well, rapidly. Wasting time waiting for hi-fidelity graphics and art to render is not the best use of time and resources. This becomes even more important as the project grows.</p><p>I hope the story was worth the read, but more importantly, I hope it paints (no pun intended) a picture of why game creators value the no-asset prototyping phase so much. In my opinion, it’s the most important phase of creating your work of art.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3813a0c1a70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prototype to Work of Art]]></title>
            <link>https://medium.com/@amber.codes/prototype-to-work-of-art-7b3bef8f6f3e?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b3bef8f6f3e</guid>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Tue, 26 Jul 2022 01:33:47 GMT</pubDate>
            <atom:updated>2022-07-26T01:33:47.162Z</atom:updated>
            <content:encoded><![CDATA[<h4>Converting Prototype Objects to 2D Sprites in Unity</h4><figure><img alt="Zombie with graveyard in the background" src="https://cdn-images-1.medium.com/max/1024/1*f8BslD9GA6PDJn8XI2k7Kg.png" /><figcaption>Images Courtesy of <a href="https://www.gameart2d.com/">Game Art 2D</a></figcaption></figure><p>Prototyping is the most efficient way to proof a game idea. It’s a tool that keeps you focused on the task at hand — ensuring that the core gameplay is fun and engaging. What happens when you are ready to throw off the shackles of gray boxes and make your game come alive with art? Within Unity, It’s as easy as drag and drop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_KsufR3_i9ZlTnoD1-Qug.png" /><figcaption>Simple Prototype Objects</figcaption></figure><p>In this example, we’ve been prototyping with simple cubes and spheres. Now, we want to convert our game objects into the actual 2D sprites. The first step is to import your sprites into your project. To do this, simply drag the items from where they are located on your computer, into Unity. Specifically, drag the items into the Assets folder inside the Project pane. As a bonus tip, creating folders for different types of assets is a great way to keep organized and will serve you well as project grows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*19dmTj7o6-RATWB3lYdrYw.gif" /><figcaption>Drag Assets Into Unity Project Panel</figcaption></figure><p>Before you begin changing objects and adding new ones, you will need to toggle the 2D setting on. This can be found on the View toolbar.</p><figure><img alt="Unity view toolbar with 2D view toggled on" src="https://cdn-images-1.medium.com/max/614/1*ih3Oi28kS0t2SmSvpl94bw.png" /><figcaption>Unity’s View Toolbar</figcaption></figure><p>We’ll review the two most common categories of items that will need to be converted — Prefabs and 3D objects. First up, prefabs. The general approach I like to take is to remove any unnecessary components, replace them with the appropriate components, add a 2D Renderer component, and assign your sprite. Let’s take a more detailed look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KbP4OIo5kOI-QppQ-p3vxg.gif" /></figure><ol><li>Open the prefab inside the <a href="https://docs.unity.cn/cn/2018.3/Manual/LookDevView.html">Look Dev view</a></li><li>Remove all components from the object except for the Transform component and any attached scripts. You can simply right-click on the component and select the ‘Remove’ option.</li><li>Replace any removed colliders or rigidbody components with their 2D counterpart, making sure to transfer any settings that were on the 3D versions.</li><li>Add a Sprite Renderer component and assign the sprite to the ‘Sprite’ field. Adjust any transform values as desired.</li></ol><p>Now, onto the plain 3D objects you may have hanging out in your hierarchy. The approach is essentially the same as with prefabs. However, the most efficient path will most likely be to delete and rebuild the object instead of converting the existing object. Before you jump in and start trashing things willy-nilly, similar to prefabs, you need to make note of any components and settings that are attached to your object. Here is the process I recommend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g465FDUrdH3AjI9P1Wc7VQ.gif" /></figure><ol><li>Drag the new sprite into your hierarchy.</li><li>Take a look at the object you’re replacing. For each component on the object, switch to the new sprite object and add the 2D counterpart. Again, making sure to transfer any settings that were on the 3D versions.</li><li>Attach any scripts that reside on former object to the new object as well</li><li>Now it is safe to delete the outdated gray shape and enjoy your spanking new 2D sprite object</li></ol><p>Happy Gaming!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b3bef8f6f3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity Byte: Controlling Hierarchy Chaos]]></title>
            <link>https://medium.com/@amber.codes/unity-byte-control-hierarchy-chaos-4c106990bd1?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c106990bd1</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[game-design]]></category>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Thu, 21 Jul 2022 13:03:16 GMT</pubDate>
            <atom:updated>2022-07-22T12:18:47.860Z</atom:updated>
            <content:encoded><![CDATA[<h4>Keep your Unity hierarchy organized using parent containers</h4><figure><img alt="Star Wars Figurines Resembling a Family Portrait" src="https://cdn-images-1.medium.com/max/1024/1*KVA5uk0U96sxPFRjA6kPxw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@danielkcheung?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Daniel K Cheung</a> on <a href="https://unsplash.com/s/photos/parent?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In this quick tutorial, I want to show you one way to keep your scene hierarchy nice and organized using parent containers. This helps with debugging and being able to quickly identify what objects are currently inside of your scene. For me, it helps me to better focus on the detail I’m working with.</p><p>In my recent article describing how to use coroutines in Unity, we made a coroutine to spawn enemies until the player dies. One problem you may have noticed is that unless the enemy was somehow destroyed, the individual spawned enemy would just stay in the hierarchy with all the other spawned enemies. This would be fine if it was maybe less than five or so, but once you get a larger amount of spawned objects cluttering up your hierarchy, it becomes increasingly difficult to manage and debug your scene. An easy fix for this is to use an empty container to act as a parent object that provides all the spawned enemies a home where they all can feel loved. Let’s see how we can achieve this.</p><p><strong>The Process</strong></p><p>Step 1:<br>Create an empty container inside your hierarchy</p><figure><img alt="Adding an empty container" src="https://cdn-images-1.medium.com/max/1024/1*Uxt83jsIZUe2hdqHFwVQyg.gif" /><figcaption>Adding an Empty Container to the Spawn Manager Object</figcaption></figure><p>Step 2:<br>Create a variable with a [SerializedField] for your new container inside the spawn script and assign it as the parent to your instantiated enemy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ab841e733138c2d2d192a6e70f1fe26/href">https://medium.com/media/6ab841e733138c2d2d192a6e70f1fe26/href</a></iframe><p>Step 3:<br>Inside of Unity, attach the container to the SpawnManager</p><figure><img alt="Adding empty container to spawn manager" src="https://cdn-images-1.medium.com/max/1024/1*BauMxZnWE1jeMxLc2c-HNw.gif" /><figcaption>Attaching the Container to the Spawn Manager’s Serialized Field</figcaption></figure><p>Happy Gaming!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c106990bd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity Basics: Coroutines]]></title>
            <link>https://medium.com/@amber.codes/unity-basics-coroutines-5d59234b298c?source=rss-495b26790550------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d59234b298c</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[game-design]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Amber Chunn]]></dc:creator>
            <pubDate>Wed, 20 Jul 2022 10:31:02 GMT</pubDate>
            <atom:updated>2022-07-20T10:31:02.759Z</atom:updated>
            <content:encoded><![CDATA[<h4>How the Coroutines can help manage object timing in Unity</h4><figure><img alt="While clock with no numbers on a bright orange background" src="https://cdn-images-1.medium.com/max/1024/1*g45VkBDcWhx7dUyHTuvqgQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/es/@shmdsgn?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">stefan moertl</a> on <a href="https://unsplash.com/s/photos/time?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><em>Coroutines</em> sound scary, or perhaps fancy, depending on your perspective. However, in reality, they are a nifty tool we can leverage for common events in our games. Unity’s Coroutine method allows you to spread task(s) over several frames¹. More practically, you can think of a Coroutine as a function that is executed in intervals². Coroutines are most useful when dealing with objects that need prolonged effects, or when the modification of an object’s properties is needed over a period of time, instead of the standard single frame. “<em>How do you use this magic</em>?”, you exclaim. I’m glad you asked.</p><p>Before we dive into code, here are the main points you need to know when working with coroutines in Unity. First, coroutines make use of C#’s <a href="https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerator?view=net-6.0">IENumerator()</a> interface, and to be valid, they must contain at least one <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/yield">yield</a> statement. Second, as per normal functions, you will need to define the coroutine function and then invoke the function in order to actually make use of it. One final thing to note is that unlike general programming norms, you will sometimes want to use an infinite loop. “<em>What!</em>?” Yep, infinite loops are often used inside coroutines for different effects that run over the entire time of the script. The important thing to remember is to provide some sort of delay between spawns so that the hardware your game is running on does not run out of resources, as this will crash your game. If done correctly, this will help make your code more efficient, as you won’t need to bombard the Update() method with extra function calls on each frame.</p><p>In our example, we would like to spawn enemies while our game is running. We want this to happen in constant intervals for the entire life of our player. When our player dies, the spawning variable will change to false and the perpetual stream of enemies will end. We will be using a spawn manager script to house our code for our spawn routine, make sense? Good!</p><p><strong>Step 1: Set Up Boolean Spawn Variable<br></strong>Inside our spawn manager file, we will add a private variable to track wether the spawning mechanism is active or not.</p><p><strong>Step 2: Create Coroutine Function<br></strong>For our function, we want to create a (<em>mostly</em>) infinite loop that continuously spawns enemies until our player dies. To do this, we set up a while loop that checks our _enemySpawn variable as the condition. Remember, the only thing responsible for stoping this loop is this variable. Once we set up our loop, we can add our spawn functionality. We simply instantiate a new enemy prefab at a random horizontal point, with the vertical point set to the top of the screen. Lastly, we add the cooldown time period.</p><p><strong>Step 3: Invoke coroutine<br></strong>Now all that’s left is to kick off our newly minted coroutine! We will do this as soon as our script starts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd1870ac355f40e9e2dc0612e98ddb00/href">https://medium.com/media/bd1870ac355f40e9e2dc0612e98ddb00/href</a></iframe><p>Voilà! We now have enemies spawning until our player expires.</p><p>Happy Coding!</p><p>Reference:<br>1. <a href="https://docs.unity3d.com/Manual/Coroutines.html">https://docs.unity3d.com/Manual/Coroutines.html</a><br>2. <a href="https://learn.unity.com/tutorial/coroutines">https://learn.unity.com/tutorial/coroutines</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d59234b298c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>