Learn Unity – Discussion working project make money

Discuss Unity Unity is a cross-platform game engine initially released by Unity Technologies, in 2005. The focus of Unity lies in the development of both 2D and 3D games and interactive content. Unity now supports over 20 different target platforms for deploying, while its most popular platforms are the PC, Android and iOS systems.

Learn Unity – The Slider working project make money

Unity – The Slider In this chapter, we will learn about the last UI element in this series. The Slider is commonly used where a certain value should be set between a maximum and minimum value pair. One of the most common usage of this is for audio volume, or screen brightness. To create a slider, go to Create → UI → Slider. A new Slider element should show up on your scene. If you go to the properties of this Slider, you will notice a ist of options to customize it. Let us try to make a volume slider out of this slider. For this, open the ButtonBehaviour script (you can rename the ButtonManager GameObject as it is certainly doing more than just managing a button now) and add a reference to the Slider. We will also change the code around a bit again. public class ButtonBehaviour : MonoBehaviour { int n; public Text myText; public Slider mySlider; void Update() { myText.text = “Current Volume: ” + mySlider.value; } } Understand how we are using the Update method to constantly update the value of myText.text. In the slider properties, let us check the “Whole Numbers” box, and set the maximum value to 100. We will set the color of the text through its properties for a more visible color. Let us follow the same procedure of dragging the Slider GameObject onto the new slot, and hit play. It is highly recommended you explore and experiment with the other UI controls as well, to see which ones work in which way. In our subsequent section, we will learn about lighting, materials and shaders.

Learn Unity – The Particle System working project make money

Unity – The Particle System Particle Systems help in generating a large number of particles with small lifespans in an efficient manner. These systems undergo a separate rendering process; they can instantiate particles even when there are hundreds or thousands of objects. Now, particles are an ambiguous term in the Particle System; a particle is any individual texture, material instance or entity that is generated by the particle system. These are not necessarily dots floating around in space (although they can be!), and they can be used for a ton of different scenarios. A GameObject manages a Particle System with the Particle System component attached; particle systems do not require any Assets to set up, although they may require different materials depending on the effect you want. To create a particle system, either add the component Particle System through the Add Component setting, or go to the Hierarchy, and select Create → Effects → Particle System. This will generate a new GameObject with the particle system attached. If you look at the properties of the Particle System, you will see that comprises many modules. By default, only three modules are active; the Emission, Shape and the Renderer. Other modules can be activated by clicking on the small circle next to their name. To the right of some values, you may notice a small black arrow. This allows you to gain more control over the values of each individual particle. For example, you can set the Start Size to Random between Two Constants to tell the Particle System to render different sized, random particles like a water hose.

Learn Unity – Using the Asset Store working project make money

Unity – Using the Asset Store The Asset Store is one of Unity’s greatest strengths in the game engine market; it comprises a large number of assets, tools, scripts and even entire readymade projects for you to download. To use the Asset Store, you need to have a valid Unity ID. If you do not have one, you can create one at the Unity website. Once you create a Unity ID, click on the Asset Store tab in the same row as the Scene View. Once you login, you should be able to see your username on the top right. In this example, we will be importing the Survival Shooter Tutorial project. To do so, we will search for it in the tab, and click on the asset published by Unity. We will hit Download, and let it complete. Once it finishes, the Download button will change to Import; click on it again to import your new Asset to the currently open project. (Note − in this particular case, we are importing a full project; in case Unity warns you about this, create a new project or overwrite the existing one if you want. Either way is fine.) A new window will pop up, listing all the contents of the new Asset you just imported. Depending on what you downloaded, this could be a single file, or a bunch of files, or entire tree with hierarchies of folders and files. By default, Unity will import all asset components when you hit Import, which is what we want. Now, let us click on Import for Unity do its job. Attempting to download assets without paying for them is illegal, and always has the possibility of viruses, bugs or lack of updates.

Learn Unity – Materials and Shaders working project make money

Unity – Materials and Shaders In this chapter, we will learn about materials and shaders in brief. To understand better, we will create a new 3D Project instead of our current 2D one. This will help us see the various changes. Once you have created the new project, go to the Hierarchy and right-click, and go 3D Object → Cube. This will create a new cube in the middle of the scene. You can look around the cube by holding right-click and dragging the mouse in the Scene View. You can also zoom in and out using the scroll wheel. Now, click on the cube, and have a look at its properties. The bottom-most property appears to have a Default material and a Standard shader. What is a material? In Unity (and in many 3D modelling aspects), a Material is a file that contains information about the lighting of an object with that material. Notice how a gray sphere denotes the material, with some light coming in from the top. Now, do not get confused with the name; a Material has nothing to do with mass, collisions, or even physics in general. A material is used to define how lighting affects an object with that material. Let us try to create our own material. Right-click in the Assets region, go to Create → Material and give it a name, such as “My Material”. These properties are not like anything we have studied so far. That is because these are properties that are programmed in the shader, not the material. Materials are what make your objects visible in the first place. In fact, even in 2D, we use a special material that does not require lighting as well. Of course, Unity generates and applies it to everything for us, so we do not even notice it is there. What is a shader? A shader is a program that defines how every single pixel is drawn on-screen. Shaders are not programmed in C# or even in an OOPS language at all. They are programmed in a C-like language called GLSL, which can give direct instructions to the GPU for fast processing.

Learn Unity – Quick Guide working project make money

Unity – Quick Guide Unity – Introduction Unity is a cross-platform game engine initially released by Unity Technologies, in 2005. The focus of Unity lies in the development of both 2D and 3D games and interactive content. Unity now supports over 20 different target platforms for deploying, while its most popular platforms are the PC, Android and iOS systems. Unity features a complete toolkit for designing and building games, including interfaces for graphics, audio, and level-building tools, requiring minimal use of external programs to work on projects. In this series, we will be − Learning how to use the various fundamentals of Unity Understanding how everything works in the engine Understanding the basic concepts of game design Creating and building actual sample games Learning how to deploy your projects to the market Let us now get started. Unity – Installation and Setting Up To create content with Unity, the main requirement is to download the Unity engine and development environment. Along with the core engine, you may also download optional modules for deploying to various different platforms, as well as tools for integrating Unity scripting into Visual Studio. To install Unity, head to Once there, click on − Choose your Unity + Download. On the next page, click on the Try Now button below Personal. This is the free version of Unity, which contains all the core features. As we begin this series, it is better to learn how to use the engine before considering a purchase to Plus or Pro. On the next page, scroll down and click to confirm that you or your company does not earn more than 100,000 USD in annual revenue. If you do, you are not allowed to try Unity Free, although you may sign up for a free 30-day trial of the Pro version. Next, click on your desired platform for installing Unity. In this series, we will be dealing with the Windows version of the engine. It is also possible to install Unity on Ubuntu and some additional Linux systems see for more information It is also highly advised that you install the latest version of , which provides many useful tools over the standard MonoDevelop IDE that ship with Unity. Once the installer is downloaded, go through it until you reach a menu for selecting what components you wish to install with Unity. Here, select the components that you will need. For this series, we want to install the components you see in the image. This selection includes the engine itself, the documentation for the engine, an IDE; build tools for Android and a collection of assets that you can add in your project later on. Click next, follow through the instructions and options, and let Unity download and install itself on your computer. Open up Unity, and in the next lesson we will create our first project. Creating your First Project Unity is equally suited for both 2D and 3D games. All games made in Unity start out as Projects from the Startup Screen. Open your newly installed copy of Unity; a screen will appear as shown below − Your existing projects will show up in the blurred region as in the above image. On the top-right corner of the window, you will see the New icon as shown above. Upon clicking the icon, you will come across the Project Setup screen. Here, you can give your project a name, set the location to where it is saved, set the type of project and add existing assets. For now, let us name our first project “Hello World!” and set it to 2D mode. Click Create Project and let Unity set up your project’s core files. This may take time depending on your computer speed, pre-added assets and type of Project. Knowing the Engine Once your new project is created and Unity opens, the following screen appears − Let us have a quick run-through of what is visible in this window. For the time being, we are concerned with four main regions − This window is where we will build our Scenes. Scenes are levels in which everything in your game takes place. If you click on the small Game tab, you can see a Preview window of how the game looks like to the player. For now, it should be a simple, blue background. This region is the Inspector. It is empty for now, because we do not have any objects in our scene. We will see how the Inspector is used later on. This window is the Scene Hierarchy. It is where all the objects in your currently open scene are listed, along with their parent-child hierarchy. We will add objects to this list shortly. Finally, this region is the Project Assets window. All assets in your current project are stored and kept here. All externally imported assets such as textures, fonts and sound files are also kept here before they are used in a scene. In the next lesson, we will discuss the workflow and working of a game in Unity. How Unity Works? In Unity, all gameplay takes place in scenes. Scenes are levels in which all aspects of your game such as game levels, the title screen, menus and cut scenes take place. By default, a new Scene in Unity will have a Camera object in the scene called the Main Camera. It is possible to add multiple cameras to the scene, but we will only deal with the main camera for now. The main camera renders everything that it sees or “captures” in a specific region called the viewport. Everything that comes into this region becomes visible for the player. You can see this viewport as a grey rectangle by placing your mouse inside the scene view and scrolling down to zoom out the scene view. (You can also do so by holding Alt and dragging Right-click). A scene itself is made out of objects, called GameObjects. GameObjects can be anything from the player’s

Learn Unity – Starting with UI working project make money

Unity – Starting with UI In this section, we will learn about the design process for User Interface or UI elements in Unity. This includes the base setup, as well as an overview of the common elements that ship with Unity. The workflow for designing UI in Unity follows a slightly different path than the one we have been going through so far. For starters, UI elements are not standard GameObjects and cannot be used as such. UI elements are designed differently; a menu button which looks correct in a 4:3 resolution may look stretched or distorted in a 16:9 resolution if not set up right. UI elements in Unity are not placed directly onto the scene. They are always placed as children of a special GameObject called the Canvas. The Canvas is like a “drawing sheet” for UI on the scene, where all UI elements will render. Creating a UI element from the Create context menu without an existing Canvas will automatically generate one. Let us now look at the Canvas GameObject to know about the additional new components − The Rect Transform at the top appears to have many new properties that a standard GameObject’s Transform does not have. This is because while a normal GameObject’s Transform describes an imaginary point in 3D space, a RectTransform defines an imaginary rectangle. This means we need additional properties for defining exactly where the rectangle is, how big it is and how it is oriented. We can see some standard properties of a rectangle like the Height and Width, as well as two new properties called Anchors. Anchors are points that other entities can “lock” onto in the Canvas. This means that if a UI element (say, a button) is anchored to the Canvas on the right, resizing the Canvas will ensure that the Button is always on the relative right of the Canvas. By default, you will not be able to modify the shape of the canvas area, and it will be a comparatively gigantic rectangle around your scene. Next is the Canvas Component. This is the master component that holds a couple of universal options as to how the UI is drawn. The first option we see is the Render Mode. This property defines the method that is used to draw the Canvas onto the game’s view. We have three options in the dropdown list. Let us learn about the options in our subsequent sections. Screen Space – Overlay This mode is the most standard for menus, HUDs and so on. It renders UI on top of everything else in the scene, exactly how it is arranged and without exception. It also scales the UI nicely when the screen or game window size changes. This is the default Render Mode in the Canvas. Screen Space – Camera Screen Space – Camera creates an imaginary projection plane, a set distance from the camera, and projects all UI onto it. This means that the appearance of the UI in the scene depends heavily on the settings used by the camera; this includes perspective, field of view, and so on. World Space In World Space mode, UI elements behave as if they were normal GameObjects placed into the world. They are similar to sprites, however, so they are typically used as part of the game world instead of for the player, like in-game monitors and displays. Because of this nature, you can directly modify the values of the Canvas RectTransform in this mode. The Canvas Scaler is a set of options that lets you adjust the scale and appearance of the UI elements in a more definitive way; it allows you to define how UI elements resize themselves when the size of the screen changes. For example, UI elements can remain the same size regardless of as well as in ratio to the screen size, or they can scale according to a Reference Resolution. The Graphics Raycaster deals primarily with raycasting (link to Unity Documentation for Raycasting) the UI elements and ensuring user-initiated events like clicks and drags work correctly.

Learn Unity – Coroutines working project make money

Unity – Coroutines Coroutines are the most helpful tools when making games in Unity. Let us consider the line of code shown below to understand what coroutines is all about. IEnumerator MyCoroutineMethod() { // Your code here… yield return null; } Generally, if you call a function in Unity (or C#, really), the function will run from start to finish. This is what you would consider “normal” behaviour as far as your code is concerned. However, sometimes we want to deliberately slow down a function or make it wait for longer than the split second duration that it runs. A coroutine is capable of exactly that: a coroutine is a function that is capable of waiting and timing its process, as well as pausing it entirely. Let us consider an example to understand how a coroutine works. Say we want to make a square that changes its color between red and blue in 1-second intervals. To begin with, we create a sprite. Next, create a new script, and name it ColorChanger. In this script, we get a reference to the Sprite Renderer of the sprite. However, we will use a different way of getting the component. Instead of dragging and dropping the component into a slot like we have done so far, we will ask the code to detect the component itself. This is done through the GetComponent method, which returns the first matching component it detects. Since we only use one Sprite Renderer per object, we can use this method to automatically detect and get a reference to our renderer each time. Remember that the renderer is responsible for making the sprite actually visible on-screen. The renderer has a color property that affects the global color of the sprite; this is the value that is to be modified. Making the Color values public will let us pick them through the editor in your operating system’s default color picking program. private SpriteRenderer sr; public Color color1; public Color color2; void Start () { sr = GetComponent<SpriteRenderer>(); StartCoroutine(ChangeColor()); } IEnumerator ChangeColor() { while (true) { if (sr.color == color1) sr.color = color2; else sr.color = color1; yield return new WaitForSeconds(3); } } Now, we will trap our coroutine function in a while loop. To create a coroutine in C#, we simply create a method that returns IEnumerator. It also needs a yield return statement. The yield return statement is special; it is what actually tells Unity to pause the script and continue on the next frame. There are a number of ways that can be used to yield return; one of which is to create an instance of the WaitForSeconds class. This makes the coroutine wait for a certain amount of real-world seconds before continuing. Let us compile our code and head on back to Unity. We will simply pick our alternating colors, and hit play. Our object should now switch between the two colors in 3 second intervals. You can make the interval a public variable and adjust the frequency of the color changes as well. Coroutines are extensively used for timed methods, like the one we just did. The variety of WaitForX methods have their own uses. Coroutines are also used to run “on the side” processes that run on their own while the game runs simultaneously. This is useful, for example, to load off-screen parts of a large level while the player starts at one point.

Learn Unity – Introduction to Audio working project make money

Unity – Introduction to Audio There is a reason games put emphasis on audio; it is quite crucial to add aesthetic value to the game. From the very first Pong, one can hear beeps and boops from the ball hitting the paddles alternatingly. It was a really simple short square wave sample at the time, but what more could you want from the grandfather of all video games? In real life, many things affect the way you perceive sound; the speed of the object, what type of scenario it is in, and what direction it is coming from. There are a number of factors that can create unnecessary load on our engine. Instead, we try to create an idea of how our sound would work in our game, and build around that. This becomes especially prominent in 3D games, where there are 3 axes to deal with. In Unity, we have dedicated components for audio perception and playback. These components work together to create a believable sound system that feels natural to the game. Unity provides us with an array of useful tools and effects like reverb, the Doppler effect, real-time mixing and effects, etc. We will learn about these in our subsequent chapters. The Audio Components In this section, we will learn about the 3 primary components related to audio in Unity. AudioSource The AudioSource component is the primary component that you will attach to a GameObject to make it play sound. It will play back an AudioClip when triggered through the mixer, through code or by default, when it awakes. An AudioClip is simply a sound file that is loaded into an AudioSource. It can be any standard audio file, such as .mp3, .wav and so on. An AudioClip is a component within itself as well. AudioListener An AudioListener is the component that listens to all audio playing in the scene, and transfers it to the computer’s speakers. It acts like the ears of the game. All audio you hear is in perspective of the positioning of this AudioListener. Only one AudioListener should be in a scene for it to function properly. By default, the main camera has the Listener attached to it. The Listener doesn’t have any exposed properties that the designer would want to care about. Audio Filters The output of an AudioSource or intake of an AudioListener can be modified with the help of Audio Filters. These are specific components that can change the reverb, chorus, filtering, and so on. Each specific filter comes as its own component with exposed values to tweak how it sounds. Playing a Sound Let us try making a button that plays a sound when it is clicked. To get started, we will Create a Circle sprite, and make it red. Now, let us attach an Audio Source to this sprite. For the object to play a sound, we have to give it one. Let us use this sound effect for our purpose. Download the sound effect, and drag it into the Assets. When Unity imports this asset as a sound file, it automatically is converted into an AudioClip. Therefore, you can drag this sound clip from the Assets directly onto the Audio Clip slot in our sprite’s Audio Source. After you drag the sound clip from the Assets directly onto the Audio Clip slot in our sprite’s Audio Source, remember to unselect “Play on Awake” in the Audio Source properties; not doing so will make the sound play the moment the game starts. Now, let us jump into our code. Create a new script called “BellSound” and open it up. Since our Audio Source is controlled through code, we want to first get a reference to it. We will use the GetComponent method like before. public class BellSound : MonoBehaviour { AudioSource mySource; // Use this for initialization void Start () { mySource = GetComponent<AudioSource>(); } Now, let us set up the method to detect the object being clicked. MonoBehaviour gives us just the method we need for it, named OnMouseDown. The method is called whenever the mouse clicks in the range of a collider of that gameObject. Since we have not attached a collider to our button yet, let us do so now. We will not need a Rigidbody for this one; neither do we need to access this collider by code. It just has to be there for the method to work. Let us test the method and see if it is working. Write the following code in your script, and attach it to the button. void OnMouseDown() { Debug.Log(“Clicked!”); } Once you save the script and attach it, play the game. Clicking on the button should spawn a message in the Console. You are now one step away from playing the sound. All you have to do now is call the Play method in the Audio Source instance. void OnMouseDown() { mySource.Play(); } Save your script, and run it in the game. Click on the button, and you should hear the sound play! Note − Consider making a button that goes up in pitch every time you click on it. Use mySource.pitch and a counter and see if you can figure it out.)