<?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 Jon Short on Medium]]></title>
        <description><![CDATA[Stories by Jon Short on Medium]]></description>
        <link>https://medium.com/@fourshortsmusic.jsshort?source=rss-8f49bd58441d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rINeJHkh5_Em_klvgrl83w.jpeg</url>
            <title>Stories by Jon Short on Medium</title>
            <link>https://medium.com/@fourshortsmusic.jsshort?source=rss-8f49bd58441d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:29:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fourshortsmusic.jsshort/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[Day 200: Hitbox Attack System Unity2D]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-200-hitbox-attack-system-unity2d-11373dc313ee?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/11373dc313ee</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Wed, 17 May 2023 17:51:20 GMT</pubDate>
            <atom:updated>2023-05-17T17:51:20.093Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: Creating a hitbox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*AxrutSIXFjTY6ck7-5yalQ.gif" /></figure><p>You can see the hitbox on the sword. How did I make that?</p><p>So I started by creating a UI box, and putting BoxCollider2D that is being used as a trigger, and a Rigidbody2D with gravity at 0.</p><p>I called this Hit_Box, and made it a child of the player sprite. I then went to the Attack animation and for each frame, I adjusted the hitbox collider around the sword.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oOo6ZduBk_yvay68CkUZgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NxAmo-e7hX9N6E77njQ4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3Lwl1F7bTGmpRf-wfSkhQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TXzE28jxsoA2NiyRfliYxw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ukVB_GuGS-9KSltJSnyqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQTvwAh2QBxrOeKdhfXYxQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9L6QNyU3FD8rcYadlMIDmQ.png" /></figure><p>I then created 2 new layers. One for the Sword, and one for the Player. Then in Project Settings I had the Sword ignore the player.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*hK_Sjd47NBCG-rv5kLo0Jw.png" /></figure><p>This is int he Physics 2D section.</p><p>It does take some time, because you have to adjust for every frame of the attack. In this case there are 17 frames, so I had to adjust it 17 times.</p><p>Note: when adjusting the Hitbox, be sure that the record is turned on in the animation, otherwise it will not change.</p><p>Also, I don’t want this hitbox on all the time, so I turned it off, and then recorded the turn on in the first frame of the animation.</p><p>That’s it.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11373dc313ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 199: Abstract Classes in action]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-199-abstract-classes-in-action-357c87085b7d?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/357c87085b7d</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Mon, 15 May 2023 13:18:36 GMT</pubDate>
            <atom:updated>2023-05-15T13:18:36.681Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: Setting up inherent classes and abstract classes in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*uU1IuhjvIRzr78qkjaF0EQ.gif" /></figure><p>This is the Skeleton enemy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*lEMmgA-OPxE08ZyAm_YnkA.gif" /></figure><p>This is the Spider enemy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*9e2ebmLP9wVd-hPCxg0c3A.gif" /></figure><p>This is the Moss Giant enemy.</p><p>What do they have in common? There movement is the same. They idle, walk idle, walk back.</p><p>So I have put all of there movements into the Enemy script, and then it is called in each of the different enemy scripts because I have them using then Enemy class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*ULq1BquS39DdjXIKM0E2dw.png" /></figure><p>Here is what my enemy script looks like now:</p><p>First I have my protected variables serialized at the top from before, then I added a protected Vector3 called currentTarget. I then added a protected Animator called anim and a protected SpriteRenderer call sprite.</p><p>These will represent the different animations and sprites that I have used in each of the different enemies.</p><p>I then created a public virtual method called Init() that is used to initialize all of the components (this is used and then put in the start method.) I have then initialized my animator and my sprite renderer.</p><p>Then in start I added the Init() method.</p><p>In public virtual void Update() I am looking for the Current Animator State Info for the the first level (I only have one level of animator) and then getting it by name which is Idle (it is idle for all of the different enemies).</p><p>I then run the Movement method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*kX4AvhE5_ECJhdVmkF9-6w.png" /></figure><p>The public virtual void Movement() says that if the currentTarget is pointA.position then the sprite should flip on X to face left, otherwise it should not flip on X and face right.</p><p>Then if the position of the enemy is the same as the position of pointA, then the current target is the position of pointB and then trigger the Idle animation. Else if the position of the enemy is the position of pointB then the current target is the position of pointA and then trigger the idle animation.</p><p>Then it is going to use the position of the enemy to be set equal to a Vector3.MoveToward the current position toward the current target at the speed that has been set in the inspector * time.deltaTime.</p><p>I then just make sure that each enemy is running as an Enemy instead of Monobehavior and I add the Init method incase I need to initialize something special within that enemy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*LKbJEA_xJ1esm7cd0ALGpw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*Nk5KTHfuQB0_qzddtBuPhQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*icv4uShdVmqcI6Oa6OM6mg.png" /></figure><p>That’s it.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=357c87085b7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 198: Designing Enemies using Abstract Classes]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-198-designing-enemies-using-abstract-classes-19177168d380?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/19177168d380</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Fri, 05 May 2023 15:56:00 GMT</pubDate>
            <atom:updated>2023-05-05T15:56:00.191Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: Creating Class Inheritance and Abstract Classes.</p><p>In order to make things work more efficiently, I am going to create some class Inheritance and Abstract classes for my enemies. Why? Well, all of the enemies have shared attributes, though the values of those attributes may differ, they all have them. If we create an abstract enemy that shows the attributes, then we only have to define the attributes for each enemy (we don’t have to completely write them again.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*DSvajZ4bT9J5UlmJzpc7tg.png" /></figure><p>Above is my Enemy script. This is a blueprint of what all of my enemies have. They all have a health, a speed, a number of gems, and an attack method.</p><p>Now in my MossGiant script I changed the class type from MonoBehaviour to Enemy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*vtb118GAK9D7YDGFFtbp5Q.png" /></figure><p>Now when I add the MossGiant script to the Moss_Giant_Enemy, it has Health, Speed, and Gems already added to the script, because it is getting them from the Enemy Script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*MMtxglpiPZ03K-UZbtE4ow.png" /></figure><p>Initially, I made all of the variables in the Enemy script public. However, I don’t want other elements or scripts to be able to access them unless they are attached to the Enemy class. I can’t make them private, because then ONLY the Enemy class can access them, so I am going to make them protected. That way ONLY the Enemy class and anything using the Enemy class can access them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*ELDE7UC-mE-WoVjFQGklyA.png" /></figure><p>So far we have created a great inheritance set up, but now we are going to make it abstract. So if we look at the code above, we see an attack method, however, what if one enemy has a different attack method then the other enemies, however the base attack for all enemies is the same. For example, my Moss Giant has a special thing that it will do when attacking, that is not the same as the other enemies, but the basic attack functions are still there. I am going to add virtual to the method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*4IB_hSm-wh1MR4IUuBJy7g.png" /></figure><p>Now if I want my spider to run a special attack after the base attack I would use the word override. (I don’t have to add the base attack at all, if I don’t want to).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*v253TnpvXzPYJuVP7SYByQ.png" /></figure><p>What if you want to require that every enemy has the same method, like the Update method.</p><p>I can make my enemy class a public abstract class and then create a public abstract implementation so that it is now required of every script that is accessing the Enemy class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*5DVaF8x9Y7uYMqeT3YiTqQ.png" /></figure><p>Here I created the abstract class and the abstract void Update.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*LhDIV-oVR05PgF8aplIuYA.png" /></figure><p>Here it is not going to allow me go move forward until I add the abstract void Update to the script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*QR5xRqMIDbPKYwrhkBLSgA.png" /></figure><p>Now it is happy.</p><p>What if I don’t want the abstract update? I can override the update and that will fix it as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*_NNQS5oqnGtAtZpLeScliw.png" /></figure><p>So as an example of the Moss Giant at work, Here you can see the Enemy Script and then the Moss Giant movement script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*0zilo86LwS2pwdP0lfu2TQ.png" /></figure><p>You can see that I added a pointA and pointB Transform here in the Enemy script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*OfXD0Ywvt3JkASNHqS4Hbg.png" /></figure><p>And here I am using those points in the MossGiant script.</p><p>Abstract classes and Inheritance classes can be difficult to understand, however, once you are able to understand them, they make things easier to create and it makes it run much smoother.</p><p>That’s it</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19177168d380" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 197: Camera Follow System in Unity]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-197-camera-follow-system-in-unity-3129d645edad?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3129d645edad</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Thu, 04 May 2023 13:49:11 GMT</pubDate>
            <atom:updated>2023-05-04T13:49:11.020Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: Create a camera follow system in Unity using Cinemachine.</p><p>To use Cinemachine, you first need to install Cinemachine, so If you click on the Windows tab, it will drop down. Go to Package Manager and it will open a window that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*X0m0KT1iHUgEDCB9RDn8CA.png" /></figure><p>Be sure to select the package that you want from the dropdown to be Unity Registry. Then find Cinemachine and click install (I have already installed it, but it will be where mine says remove).</p><p>Now time to create a virtual camera. If you are using an older version of Unity, it will have a tab at the top that says Cinemachine. I am using the 2021.3.19f1 version which puts Cinemachine under the GameObject tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*O5T0icf0WL_zEE5F9GoB6Q.png" /></figure><p>In my new Cinemachine Camera, I added the Player to the Follow position, and changed the z position to -10.</p><p>Now I have a camera that will follow the player wherever the player goes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*JIdQDANAFdvardct1g73EA.gif" /></figure><p>That’s it.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3129d645edad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 196: Creating Player Movement]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-196-creating-player-movement-bc3a025bb9fc?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc3a025bb9fc</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Wed, 03 May 2023 13:14:31 GMT</pubDate>
            <atom:updated>2023-05-03T13:14:31.454Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: To create player movement without using a grounded variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*pXTbykmaJ63tCBxoMkMisQ.gif" /></figure><p>In the past, we have accomplished the movement, jump, etc. by creating a variable for isGrounded in order to cast a raycast to the ground and check if the player is grounded so that they can jump. A more efficient way to accomplish this is to create a bool method that checks if the player is grounded. So, here is my player script, and an explanation of what is happening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*bg3_NS7PcTJHNSIPhezUsw.png" /></figure><p>So the variables that I have created are for the speed, jumpforce, a restJump bool and a Rigidbody2D</p><p>In start I am grabbing the rigidbody2D.</p><p>In update I am calling the Movement method.</p><p>No for the movement method:</p><p>It says that I have a float called move that is going to get the Horizontal input and get it “raw” so that it moves within the physics more smoothly.</p><p>Then it is going to get the rigidbody2D velocity and set a new Vector 2 which is the move variable times the speed and whatever the velocity of y is currently.</p><p>Then if I press the space key and the IsGrounded method is true, then I am going to have a new Vector2 that has the rigidbody velocity of x and the jumpForce.</p><p>I will then start a coroutine called ResetJumpRoutine().</p><p>Now the bool method IsGrounded says that it is going to have a RaycastHit2D called hitInfo and set that equal to the Physics2D.Raycast which is the players position, the raycast is going down at a distance of 0.6f and it is using a laymask that is looking for the ground and the layer mask is 1 &lt;&lt; 8.</p><p>if the hitInfo.collider is not null and if resetJump is false, then it will return true otherwise it will return false.</p><p>The coroutine says that resetJump is true then it will wait for 0.1f seconds and then set resetJump to false.</p><p>That is it.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc3a025bb9fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 195: Setting up Perspective Parallax]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-195-setting-up-perspective-parallax-ba8c4dbae16e?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba8c4dbae16e</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Tue, 02 May 2023 13:28:39 GMT</pubDate>
            <atom:updated>2023-05-02T13:28:39.295Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: Create Depth in the scene.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jcsKxQgV1w9uNTQLd8Bzyg.png" /></figure><p>Here is my scene. It is flat and boring. I want to give it depth and make it look better. How do I do that?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*mCS_9BlcZBd2gEnX_-98FQ.png" /></figure><p>The first thing I am going to do is change the Projection from Orthographic to Perspective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jS6kgj4z8_uOA7yPFsZ81A.png" /></figure><p>Doing that you can see that it moved everything closer, and game it a little more depth, but I want more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*4mlfxydoENS40wFFHftgiw.gif" /></figure><p>In the GIF above you can see that I moved the 2 grids that were behind the forground. I moved the Background Black_Cave to Z = 1 position and the GreyFar_Background to Z = 3.</p><p>Now I really have some depth, and that depth is seen as I move the camera back and forth along the game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*_K2d91FFeIi8cNGyCg_LcA.gif" /></figure><p>That’s it.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba8c4dbae16e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 194: Animated Tile Sets in Unity]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-194-animated-tile-sets-in-unity-58da52abdf4a?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/58da52abdf4a</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Mon, 01 May 2023 12:54:06 GMT</pubDate>
            <atom:updated>2023-05-01T12:54:06.001Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: Create and use animated tile sets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*sfVa80WwGqkCYWuO_LFvYg.gif" /></figure><p>This use to be much more complicated then it is now, because you had to use a 3rd party to create the animations, however, now it is all built in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*okwXOT6NqyZYygnE46jRqQ.png" /></figure><p>I started by creating a folder for my Waterfalls. I then right clicked on the waterfall folder, went to create, went to 2D, then to Tiles then to Animated Tiles and named it LeftWaterfall. I did this 2 more times for the right waterfall and the center waterfall.</p><p>I then found my waterfall sprites, and dragged them into the space where it says “Drag Sprites Here” (remember to lock your Animated Tile screen so that you can grab all of the sprites at once.)</p><p>I then set the speed to be 30, and created a new palette for the waterfalls. I then painted them where I wanted them.</p><p>that is all there is to it.</p><p>thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58da52abdf4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 193: Introduction to Tilemap in Unity]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-193-introduction-to-tilemap-in-unity-c53c7930cf27?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c53c7930cf27</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Fri, 28 Apr 2023 13:09:14 GMT</pubDate>
            <atom:updated>2023-04-28T13:09:14.302Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: how to set up Tilemap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*MtisJDAa2tKzyOjTlv9wZQ.png" /></figure><p>Tilemap is used to paint a 2D enviornment (at least in this case), and I have set it up to work on the ground. First of all you have to be working in Unity 2D, then I am going to create a tilemap object in the hierarchy. If you are using a newer version of unity (I am using 2021.3.19) then you are going to need to select the rectangular grid.</p><p>Once that is done, name it Ground_Tilemap and then open up your Tile Palette window (I found this under the Window tab and then went down to 2D.)</p><p>In the Palette window, you are going to click on the drop down that is shown below, and create a new palette.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*Exqsts0CrqPHi4iuPpaiwQ.png" /></figure><p>You will then need to save your new palette. I saved it under sprites, then created a folder called Tilemap, and within that created a folder called Palettes.</p><p>After that you are going to create your sprites. Here I downloaded the assets from Filebase, found the Enviornments folder, then the Level folder and looked to find Ground.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*jApg2Px48zKQvJa5RaxffQ.png" /></figure><p>First I turned the texture type to Sprite 2D and UI. I then hit apply. Then I turned the Sprite Mode to Multiple and then hit Sprite Editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otrNb0TAd5YJ06ewc-Rjpg.png" /></figure><p>Next I hit Slice and told it Grid by Cell Size. I made the size 128 by 128 (I was told that was the size) and hit apply.</p><p>I then set the Pixels Per Unit to 128 and then moved on.</p><p>I took the Ground sprites and moved them to the Tile Palette. This had me save it and I put it under sprites, then under tilemap. I then created a new folder called Tiles, and then inside that, a folder called ground. That is where I put those sprites.</p><p>Now I can use the tile palette to “paint” the tiles on the tilemap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*dCAbLOy5e1yPV3hRvzEhkw.gif" /></figure><p>That’s it.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c53c7930cf27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 192: UI Music Game (part 6)]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-192-ui-music-game-part-6-19ffa47c18c6?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/19ffa47c18c6</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Thu, 27 Apr 2023 13:14:49 GMT</pubDate>
            <atom:updated>2023-04-27T13:14:49.430Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: Create the Title Screen and Profile Screen and game menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*29vPImcNuw9qp7o-c_s8tw.png" /></figure><p>So we are going to cover quite a bit in this set, but they are all pretty small.</p><p>This is the title screen. It is just a title with a continue button that takes you to the profile page, and a quit button that will quit the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*tJgIBaKNvP7kjgbJ8mLWMg.gif" /></figure><p>The script looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*OmDxG3o9QY-GBrj5Lifhig.png" /></figure><p>First, I added UI and SceneManagement to to the libraries. I then have a continue button, a quit button, an audio Source and audio clip. There is also an array for flashImages that I will add later, but is not set up right now.</p><p>In the start I have the audioSource that i have gotten the component for, and the PlayBackgroundMusic method.</p><p>Under that I have the LoadLevel() that I have set up to run a load level bar, however, it went so fast, that I removed the bar for now, and might add it back in once I have more in the game itself. However, it will load the profile scene from here.</p><p>The PlayBackgroundMusic method plays the audio clip, the GoToProfile method which is what the continue button is hooked up to, and the OnApplicationQuit method which is what the quit button is hooked up to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*rTb1GPV2QZdLgoK92stiIg.png" /></figure><p>Now for the profile scene. This has been set up with a title at the top, then there are 2 text fields (really there are 4 text fields, one set for the create a profile, and one for the Login fields that are shown above.) I also have set up 4 buttons. When in the Login fields, they are the login button and the create account button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*HRRxHsQjUwjPW7krEWkA8g.png" /></figure><p>When in the create account setting, they are the create account button, and the cancel button. Then there is a text box that tells you if you are successful or not.</p><p>It works like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*MFH3_pxSrq-LHtRzfhwBrw.gif" /></figure><p>You click ont he create account button, add your username and your password and click the create account button. then you enter your username and password and click login. If you mess up it will tell you that you have done it wrong.</p><p>Here is the script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*ldaSNJqJoySXRxQ0_edaEg.png" /></figure><p>I started by adding the UI and SceneManagement and then my variables.</p><p>I have serializedfields for all of these. there is an array of userINputFields, an array of buttons, a game object for the login screen and one for the create screen. there is a text box and then a username and password and finally a gobackbutton.</p><p>In start I just need the text box to say nothing, so I set it to say nothing.</p><p>then I have my GoBack button method set up to go the the TitleScreen.</p><p>Now for the LoginAccount setup:</p><p>if the userInputFields[2].text is equal to the username and the userInputFields[3].text is equal to the password, then we are going to be doing some things.</p><p>If they username is blank or the password is blank, then it is going to prompt you to create an account, and then set those fields back to blank.</p><p>otherwise it will say that you have successfully logged in and send you to the GameSelect scene.</p><p>Now if the username or password are null it will say you have not account.</p><p>And if these userInputFields are not equal, then it will say that it is incorrect and to try again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*QAe_hF1-8-WZSZAyYRtaTA.png" /></figure><p>Now if you are creating an account you use the CreateAccount method.</p><p>It says that if the userInputFields[0].text.Length is greater than 3 and the userInputFields[1].text.Length is greater than 3 then it will do the following:</p><p>It will set the username to be the userInputFields[0].text. It will also set the password to be the userInputFields[1].text. Then the text box will say Account succesfully created. and then run the OpenLoginAccountMenu method.</p><p>If they are not long enough, then it will say that they must be at least 4 digits or more.</p><p>The other methods are as follows:</p><p>InputUsername sets the username as a PlayerPrefs, the InputPassword set the password to a PlayPrefs. the OpenCreateAccountMenu method turns the login screen off and the create screen on, and the OpenLoginAccountMenu does the opposite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*w0yG8iSDSp-uLODRc2fKYw.png" /></figure><p>Finally, there is the game menu itself. It consists of buttons that take you to the 3 games, a button to take you to the piano, and a dropdown menu that can take you back to the title, The Music player, or quit the game. It works like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*ik0kODUJDfpYmBlJ2GLHyg.gif" /></figure><p>Here is the script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*hivEPwxVzRv_xoerGla1uQ.png" /></figure><p>First I added the UI and SceneManagement. then I added all the buttons. I added them separately, however, I could have created an array for the buttons. I also added a dropdown, a gameObject for the dropdownmenu stuff, an audioClip, and an audioSource.</p><p>In start I grabbed the audioSource compoinent and set up the audioClip to play.</p><p>The dropdown menu button is set to open the dropdownmenu screen, and the close button in the dropdownmenu screen will turn it off.</p><p>Then I have the ChooseFromDropdown method which sets the values of the dropdown. if the value is 0 (title) it will go to TitleScreen. If the value is 1 it will go to MusicPlayer and if the value is 2 it will quite the application.</p><p>I then set the buttons to go to the perspective scenes.</p><p>That is it, and that is the whole game.</p><p>I plan to add more, and to change whatever I can from legacy to textMeshPro, but for now, it is done.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19ffa47c18c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 191: UI Music Game (part 5)]]></title>
            <link>https://medium.com/@fourshortsmusic.jsshort/day-191-ui-music-game-part-5-1860038783aa?source=rss-8f49bd58441d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1860038783aa</guid>
            <dc:creator><![CDATA[Jon Short]]></dc:creator>
            <pubDate>Tue, 25 Apr 2023 16:30:52 GMT</pubDate>
            <atom:updated>2023-04-25T16:30:52.310Z</atom:updated>
            <content:encoded><![CDATA[<p>Objective: Create the virtual piano and the music player.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*1jdokwKyKVwDgfrXJ9sWgQ.png" /></figure><p>This is the virtual piano that I crated. Each key is a button, and each button makes a different pitch, however, each pitch has been manipulated by changing it’s pitch value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*EJDTK0xRYrGEMS2LXEPjRg.png" /></figure><p>So for the note A3, the pitch is 1, however, if I were to choose another note that was lower then that,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*xx30Gsj4lukGHIby7aSodw.png" /></figure><p>B2 for instance, the pitch is 0.555.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*h8YN2BFmWTbjftwDoRwZSA.png" /></figure><p>However, if the pitch were higher, then the number would be higher as well. So C5 is 2.45.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*tPKnKCt-UGaspgf0UPpupA.gif" /></figure><p>To play it, you just click on the key you want to sound. When you want to go back, click on the back button.</p><p>There are 2 really simple scripts for this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*fAIiLPbkScpzqB9oaVcRFQ.png" /></figure><p>This is the audio script. It makes the actural sound happen. It has an audioClip, an audioSource, and a pitch. The method PlayKey is set up as with the audiosource.pitch set equal to the pitch, and the audioSource playing the auidoClip as a PlayOnShot.</p><p>Each piano key (button) has this script set on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*d3i-umGjfQzcBNk2wg5sDg.png" /></figure><p>Here is the piano manager, that is only here to make the go back button work.</p><p>Now for the music player:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*V83oqTRA8w-Gnjh692HTow.gif" /></figure><p>Here you can select a song play it, pause it, or go back to the main menu.</p><p>This is a toggle with the songs listed, a scroll bar to get to the songs, and 3 buttons to play, pause and go back.</p><p>Here is the script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*YR6j56OncmNgLEt8NWG_qA.png" /></figure><p>So I added the UI and SceneManagement libraries.</p><p>In the variables it has serializedfield for a toggle array (the list of songs), audioClip array (the different audioClips for the songs), and the 3 buttons. I also have a private AudioSource.</p><p>In the start menu I grab the audioSource component.</p><p>I then set up my buttons, each with there own method.</p><p>Then I have a SongSelection method that says that if the songlist[?].isOn is true, then it will play the matching audioClip.</p><p>That is it.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1860038783aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>