Unity Tutorial 05 (Semester 2)


Image from the tutorial

Throughout these tutorials I have been using a static camera within a single screen so this week I had learn how to control my camera automatically without needing to use code. This was so my camera would always follow Ruby. To do this first I had to open my packages folder and install my cinemachine package. I then had to add a cinemachine 2D camera to my scene creating a GameObject called CM vcam1. I then learned about the two different camera modes in games. The camera modes are perspective and orthographic. Perspective mode is where the lines going away from the camera converge to a point which makes objects appear smaller as they get further away from the camera. Orthographic mode is when parallel lines stay parallel. The instructions said to leave the camera in orthographic mode because since it is a 2D game things shouldn't get smaller in the distance so that's what I did. I then had to set my camera to 50 units of the world in it's height so I could see 25 units of the world. To get my camera to follow Ruby I had to drag and drop Ruby from my hierarchy to my follow property on the vcam inspector. After I did this the camera was positioned so that Ruby was center of the screen. I then painted a bigger scene and added water tiles so that Ruby wouldn't leave the map.  To stop my camera showing anything outside of my map I had to add an extension called the CinemachineConfiner. I then had to add a Polygon Collider 2D to use as bounds. I then had to create a new GameObject called CameraConfiner and add my Polygon Collider 2D to it. I then had to create points on the middle of the water on each corner. I then had to go back to my vcam1 and add my GameObject to the Bounding Shape 2D on my CinemachineConfiner however after I did this my character was pushed outside the world so of course I had to fix this. To do this I had to edit my layer and choose an empty slot and name it Confiner. After this I had to add my Confiner layer to my Confiner GameObject. After I finished this I had to create new particles. The first thing I had to do was prepare my sprites. To do this I had to select ParticleSheets in my Art folder. I then had to set the type to multiple and leave the PPU as 100. I then had to slice my sprites using my sprite editor. I then had to create a new Particle Effect called SmokeEffect. I then had to pick random sprites. First I had to set my mode to sprites and then add 2 of them. I then had to assign my sprites smoke sprites from my sprite atlas. I then had to start a frame and select random between two constraints and enter 0 and 2. I then had to click the black box next to frame over time and then select Delete Key so that I wouldn't have any animation. I then had to open my shape section in my inspector and set the cones radius to 0 so that all my cones would start from a single point. I then had to change the angle to 5. I then had to add randomness to particles. To do this I had to find the following three settings in the particle system. Start Lifetime, Start Size and Start Speed. Start Lifetime determines how long the particle will be on screen before it is destroyed. Start Size determines the size of the particle as it is created. Start Speed determines the particles speed as it is created. I then had to make the particles fade away. To do this I had to enable the colour over lifetime section by clicking the white circle next to its name. I then had to open the gradient editor to change the colour of the particle. I then had to change the alpha from 225 to 0. I then had to enable the size over lifetime section. I then had to make a prefab out of my smoke effect and delete the one in scene. I then had to open my robot prefab and make my smoke prefab a child of my robot. I then had to fix my smoke movement by going into my particle system and changing my simulation setting from local to world. I then had to open my EnemyController script and add a public class called smokeEffect. I then had to go into my fix function and add smokeEffect.Stop() and Destroy(smokeEffect.gameObject) on the next line.




Comments

Popular posts from this blog

Introduction Post

My Favourite Game: Grand Theft Auto Franchise

Game Alpha