Introduction Section For Portfolio Of Prototypes Assignment
Introduction
In this, I will be discussing how I learnt to use Unity to create the various prototypes and a lot of the challenges that I had to overcome when using Unity to finish all the prototypes that I started to make using the engine and how aspects of the engine allowed me to create them. Also, I will be discussing how I did my research outside of the taught lessons to help me improve on the prototypes that I made and a brief overview of what Unity and C# Scripting is and why it is used in Unity.
What is Unity Game Engine?
Unity is an engine that is mainly focused on being used for game creation either 2D or 3D games can be made using Unity, Unity is a program to help developers create their games more quickly since they wouldn’t have to make their own engine instead, they can use Unity to start making their games, and it provides all of the tools that they would need to do so, and it all does this a simple to understand user interface that you will navigate to access all of the tools that you need to create any projects.
Also, Unity doesn’t have to be just used for game development it has been used in many other industries such as film, automotive and architecture and many more so you can use Unity for a wide range of things, but it is mainly focused on the game development side of things.
What is C# and Scripting?
C#, also known as C Sharp, is a programming language that can be used for many tasks or any objectives that it is told to do, and this language isn’t just limited to just being used when programming for games. It can be used for any type of application that anyone would want to make with it, like programs like Photoshop. All the Microsoft Office applications were made with this language, and most software on Windows is made with C#.
This is one of the reasons why Unity uses C# since it is a commonly used coding language so if you had never used Unity before but had knowledge of C# you could get started on programming games using Unity very easily due to having previous knowledge because it is a widely used language in many professions that involve programming.
C# Scripting is used for testing out your C# code without you having to create multiple projects, so this makes it easy to test our code and to make sure everything works as intended, and this is part of the reason why scripting is used in Unity because allows them to test their code very quickly and easily and scripts in Unity are how anything you want to create is done without scripting you wouldn’t be able to do anything in Unity since you need to use C# scripting to do anything like for example if you wanted a character to move left and right you have set that up in a script to perform that task that you wanted to do, and this applies to anything that you might want to create using Unity.
How to Setup Scripting in Unity And what not to do when making a Script
Setting up scripting in Unity is very simple all you need to do is right-click on the project view this is where you will store all your assets in Unity, such as sprites, scripts, etc. By right-clicking, there will be an option to create a lot of things that you might want to use, but the thing we want to focus on is creating a C# Script you click on the option for it, and it will a C# Script file, and you can name it whatever you want it to be.
However, I don’t recommend using spaces in the names of any files for your project in Unity, especially in your scripts, because the script won’t be able to understand what the spaces are and this will cause a lot of errors when writing code in your scripts, so it easier to not include spaces in your file names because it will make that anything in your project will be able to work with the script that you created.
For example, if I wanted to reference an object in my script and it had the filename of obj player the script wouldn’t be able to understand what this means due to the spaces however if I called it obj_player the script would be able to understand what you’re trying to tell the script to do.
Also, another thing that you shouldn’t do when making a script in Unity is to change the file name of that script after you have already created it because in the script itself it will mention the name you gave that particular script and this is called a class name and if you change it the script won’t work anymore due to the file name in the project view being different than the class name in the script.
What are Variables and the types of Variables that are used in C# Scripting
Variables are names given to functions that are used to perform one task, basically, all variables store a value or information relating to our unity project like for example, it could be the player’s health, score etc. All variables need to be declared beforehand in your script, or it won’t be able to perform the task that you want it to do since you haven’t declared that variable in your script, it won’t be able to do anything.
Declaring a variable is simple to do in a script all you have to do is put the data type of the variable that you want to create and give that variable a name. For example, if I wanted something in my script to equal to true or false I would have to declare a Boolean variable and this variable will always equal to true or false.
By declaring the variable beforehand I can reference the variable later in my script by writing the name that I gave that variable, and with this, I would be able to tell the script to make a statement equal to true or false. Also, a data type defines the information that is stored in a particular variable.
Data Types
An Integer is a whole number that can be a positive or negative or even zero, and it can’t be a fraction such as, 1,120 and -20, and when creating your project in Unity, you can use this variable for the player’s health, or the player’s score and this number would increase or decrease, and this variable will only accept whole numbers so you can’t use fractions or numbers with a decimal.
A Float is a data type that can accept numbers that aren’t whole numbers so basically, the float variable is the complete opposite of an Integer as it can use non-whole numbers like fractions or numbers with a decimal, for example, 0.5, 1.35 etc. Also, when typing a float variable in your script at the end of the number that you want to set that float variable to equal to, you need to put a lowercase f at the end of the number for example 1.35f. So, when creating your unity project, you could use a float variable to determine the speed of the player object.
A String is a piece of text that is contained inside a variable like for example, when writing a string in a script, it could contain the text (“Hello World)” inside the string, and this could be used for a name of an upgrade in your game, or it could be the name of the player.