May 3rd – 7th
Class hours: 9:40 – 2:05
Mr. Bohmann | email@example.com
9:40 Attendance & Notes
- Remote Link for today (if you are not here, but you should be here)
- Make your Week 31 Folder (and remember to put your work in it)
- CTE’s Recognition Night on Thursday June 10th. Rain or shine, both cohorts, and we will be folding National Technical Honor Society induction ceremony into it!
- Cawd Server – We are retiring the server on June 1st and moving to a new server. For you, that means anything you want to keep from this year or last year you will want to download before June 1st.
- Our Objective this week is to dig in to the creation of game assets, player movement and scripting to prepare you for creating you own game.
9:50 Assignment Showcase – Sprites ! (let’s see what you made)
10:00 2D Game Development & Sprite Sheet Importing
Do you have a favorite 2D game?
The next couple of weeks we will build our own 2D platformer game. We’ll use a some of our own assets and some from the Asset store. All of your games will likely look different, however the method for which we create the game will be the similar.
Let’s start by importing the Sprite Sheet, slicing up and optimizing sprites.
Create a new 2D Project: 2DGameDev is what I am going to name my project.
For reference, I made a video on the importing sprite sheets in case someone is missing today. The only change (from the video) is when declaring the cell size in the sprite editor, it is 100 by 100 with padding of 4.
10:25 Mask Break
12:00 Intro to C# Programming
Learning a language takes time and is best learned by practicing and typing the code. Also, adding comments is super helpful. For most of the scripting we do in class, I will provide a reference sheet of code for you in case you get stuck or behind or just want to watch and add your code later.
To help learn scripting, we’ll build in a 2D environment and use some assets from the Asset Store and some of your own. Topics will include:
- Player movement
- Player animations
- Camera Scripting
- Fall detectors
- Collectibles and Scoring
- Particle Systems
- Adding Game Manager and HUDs
There are lots of jobs in the game industry. If you don’t love coding/scripting games that does not mean you cannot be a game developer. Game programmers are just one of hundreds of jobs in the field!
Ok, now on to the basics….
A script must be attached to a Unity GameObject in the scene so that we can give that GameObject instructions to do stuff (move, jump, destroy…)
C# uses Variables, Functions and Classes. Let’s see what they do:
Variables hold values and references to objects (you can see objects as “bigger” variables). They’re like a box that holds something for us to use. Variables start with a lowercase letter. Here are some common variable types:
|Type||Contents of the Variable|
|int||A simple integer, such as the number 2|
|float||A number with a decimal, such as the number 2.17|
|string||Characters in double quotes, such as, “Cawd is my program”|
|bool||A boolean, either true or flase|
Example: public float moveSpeed //this creates a variable called moveSpeed that allows us to change the speed of our character in the Inspector. We could also define the movespeed:
public float moveSpeed = 3f; //where f stands for float
Functions are collections of code that compare and manipulate these variables. Functions start with an uppercase letter. We organize code in functions so that they can be easily reused multiple times in different parts of the program.
Below are some functions that run automatically inside of Unity
- Start() // called once at the start
- Update() //called once per frame
- FixedUpdate() //used when you want physics to work
Classes are a way to structure code to wrap collections of variables and functions together to create a template that defines the properties of an object.
Coding Time – Let’s Play with the different types of variables, strings, etc….
The names and values you use do not have to be the same as mine, just make sure they are public so you can see them in the inspector. Let’s code together and look at some basics of how C# works and get comfortable with the Visual Studio editor.
1:05 Mask Break
1:15 Adding our Player Script
We’ll script our player controller together and if successful, your player will move left/right up/down and flip direction. This link will take you to a Google Doc with the code on it in case you get lost or want a copy of your own for your files (which I recommend).
If we have some remaining time today, consider adding a couple of additional GameObjects to your scene or work on your Unity Topic for tomorrow’s presentation.