Unity Tutorial 01 (Semester 2)

 



(Image of Ruby from the tutorial)

For this weeks tutorial I had to make a 2D game instead of a 3D game like in semester 1. I had to do this following tutorials for a game called Ruby's Adventure: 2D Beginner Project. I previously have had experience making a 2D game in my plc on a website called Flowlab however as I had graduated my plc 2 years ago it felt like it was all new to me especially since I didn't use Unity the first time round. For this tutorial I had to update my Unity Software to a different version then what I currently had for semester 1 so that I could create a 2D game. After this I started adding in my main character (Ruby) and then I had to make her move. To do this I had to create my first script just like in semester 1. To add my main character I had to download an image of her from the tutorial materials folder (see image above). I then had to add her to my sprites folder. I then had to make my Ruby sprite into a GameObject. I had to put this sprite into my scene view so that she would appear in my scene. I also had to use the 2D view. The scene creation process was basically the exact same as the one we did in semester 1 so none of that was new to me.  After I created the scene I had to create a new C sharp script called RubyController. Originally there was a default script that came with our editor however I had to make a few changes to make Ruby move. The first change I had to make was in my Update method in order to create a Vector2 variable. I had to add in the code Vector2 position = transform.position; position.x = position.x + 0.1f; transform.position = position; We had done Vector2 variables in semester 1 so this wasn't new to me either. After I did the basics I had to create a character controller and  keyboard input using the Unity Input System. To do this I had to edit the default input settings in the project settings window and edit my axes values.  I then had to add a float variable to my Update method called float horizontal = Input.GetAxis("Horizontal"). I then had to create a Debug called Debug.Log("Horizontal"); I then had to add *horizontal; to my position.x so that Ruby could move horizontally. I then had to type a similar code in order to make Ruby move vertically. To do this I just had to type the exact same code but replace the word horizontal with vertical and add a position.y axis and set it to 0.1f. I then had to change my timing and framerate of the game. When I originally started the tutorial the frame rate was set to 60 frames per second so I had to change this to 10 frames per second. To do this I had to add new code to my Start method called QualitySettings.vSyncCount = 0; and Application.targetFrameRate = 10; This was to make Ruby run at 10 frames per second instead of 60. I then had to go to my Update method and add Time.deltaTime to both my horizontal axis and vertical axis. After this I had to create something called a tilemap. This was to create space for Ruby to move around. Tilemaps were new to me as we hadn't done this in semester 1. The first thing I had to do was create a grid from my hierarchy. I then had add a tilemap to my grid. These were both new GameObjects. I then had to go into my art folder and create a new one called Tiles. I then had to create a new tile called FirstTile, give it a sprite and add it to my tile palette. Next up I had to connect my tiles. To do this I had to go into my Cell Size Property in my inspector and set each pixel to 64 pixels per unit. I then had to edit my tilesets using the tutorial resources. I had to choose the tileset called FloorBricksToGrassCorner. I then had to change my sprite mode in my inspector from single to multiple and set the pixels per unit to 100 this was so I could split my tileset into 9 different sprites. I then had to paint my tilemap using the tools in the tile palette toolbar. Since I have been using Unity since semester 1 most of this code wasn't new to me and I was familiar with it however making a 2D game using Unity was a whole new experience that I hope to get better at overtime. Creating the tilemap was the only thing I wasn't familiar with for this tutorial.

Comments

Popular posts from this blog

Introduction Post

My Favourite Game: Grand Theft Auto Franchise

Game Alpha