In C#, everything is associated with classes and objects. A class is simply a "blueprint" for objects, defining their values and behaviors.
🚗 We define a class Car. It has a value for gas and the ability to move.
🚙 We can instantiate many Cars. Each car is an object with the type of class Car.
✅ Thus, any changes we make in the class Car will be reflected in all the car objects we create.
⭐️ Variables, properties, and methods comprise a class.
📌 Variables hold the state (values) for the class.
📌 Properties usually are just wrappers for variables, preventing us from setting them to an invalid state.
📌 Methods implement behaviors. Your class may have methods to Move, Honk, Stop, Turn, etc.
⭐️ Private vs Public
📌 These special keywords change the access level to certain variables, properties, and methods.
🕵️♀️ Private - The type or member can only be accessed by code in the same class (or struct).
💁♀️ Public - The type or member can be accessed by any other code.
✅ Use these keywords to create an interface for your Class. So the inner details are all handled inside and external code won't change variables or call methods that put your class into an invalid state.
⭐️ Here are some interesting features we'll look up in the future. I suggest your research them beforehand.
📌 Classes may inherit behavior and values from another class. e.g. Horse class inherits from Animal class.
📌 Classes can be defined as static. Meaning, the class is the one-and-only one instance of itself.
📌 Classes have more access levels: Protected, Internal, and Protected Internal.
📌 Classes are always allocated on the Heap.
A loop statement allows YOU to execute a group of statements multiple times.
💪They are very powerful, especially if you need to execute a task N times or iterate over many objects.
⭐️ foreach loop
📌 Executes a block of statements for each instance in an array, list, or any IEnumerable.
👍 You'll see this loop often, using it to perform the same task for multiple objects.
⭐️ for loop
📌 This loop allows you to initialize variables and change them after each iteration until a condition is false.
👍 Use this if you need to keep track of the current index in an array.
👍 Good if you just need to iterate over any numbers.
⭐️ while loop
📌 Simply executes a block of statements until a condition is false. The condition is checked before the first iteration.
👍 Good for running tasks until some state has changed.
👍 e.g. Move player until they are dead. Eat food until full.
⭐️ do while
📌 Similar to the while loop, however, the condition is checked after the first iteration.
👍 Use this when you have a task you always want to run before the loop condition.
👍 e.g. Player enters input, if the input is not valid then try again, else exit the loop.
⭐️ Loops are both fun and powerful tools at your disposal.
⭐️ You may struggle with learning loops, that's ok. Things will click after hours of practice.
⭐️ If you find yourself repeating the writing them the same code over and over, consider a loop.
➡️ Follow @mefirstgames for more game dev tips.⠀
➡️ Free Unity Tools: https://www.mefirstgames.com/hierarchy-comments.html⠀
The "if else" conditional statement allows you to change the flow of your program.
For game devs, "if else" is essential to implement the features of your game.
📌 You'll use the "if" statement to determine if the player is dead, jumping, swimming, attacking, and much more.
📌 You can put any conditional in your "if" statement as long as it evaluates to true or false.
📌 You can use the logical AND operator "&&" to return true if both sides are true.
📌 Use the Logical OR operator "||" to return if either side is true.
📌 The Logical NOT operator "!" may be used to reverse the outcome of an expression.
📌 It's possible to chain many expressions using these operators, but good practice is to define a method for large conditional statements.
📌 If you are a beginner and struggling to grasp the "if else" statement, then no sweat.
📌 "If else" is a basic construct, a building block used in all programs and games.
🚀 if ( YouHaveWillToLearn() ) // then the "if else" concept will soon click.
➡️ Follow @mefirstgames for more game dev tips.
➡️ Free Unity Tools: https://www.mefirstgames.com/hierarchy-comments.html
The Control Flow of a program is the order in which the program's code executes.
As a competent programmer, you NEED to understand where you are in the Control Flow and where it can lead you.
📌 By default, your program will execute instructions in a linear order, executing each line of code after the next.
📌 This linear flow can be broken up using conditional statements and function calls.
📌 It's easy to represent the Control Flow of your program using a graph.
📌 If using GCC, you can use tools like Trucov to print the Control Flow of your program.
📌 The If-Statement and Switch-Statement will cause your Control Flow to branch.
📌 Loops will cause your Control Flow to go back to a previous node.
📌 Function calls will jump to an entirely separate part of your control flow.
✅ When you are writing lines of code, you are defining the Control Flow of your program.
✅ Where it can branch, loop, jump, break; essentially what it can do and where it can go.
✅ The cool thing about the Control Flow is that you don't have to understand the entire graph at once.
✅ The graph can be broken up or "encapsulated" into a single section.
✅ This makes it easier for us to understand; that's why we separate code into different functions and classes.
🎮 In Unity, you can think of the entire Control Flow as a huge massive graph.
🎮 But we only need to worry about the Control Flow in our own MonoBehaviors. ➡️ Follow @mefirstgames for more game dev tips.
➡️ Free Unity Tools: https://www.mefirstgames.com/hierarchy-comments.html
The Singleton design pattern keeps the instantiation of a class to a single instance. Controversial but convenient, Singletons are something you will most definitely encounter in your life as a developer.
👍Singletons are very quick to implement and can make accessing an object easy.
👍Better than static classes, they can leverage polymorphism, cache values, and have their instances swapped out.
👍They require low memory usage, low latency, and only need one initialization.
👍In Unity, it offers better performance then FindObjectOfType.
👎Controlling initialization order across Singletons can become messy very quickly.
👎Deviates from the single responsibility principle.
👎Promotes mass coupling to a single instance.
👎It can be difficult to refactor, especially if you need to change its behavior in a different context.
👎In Unity, it is difficult to track the lifecycle of the Singleton MonoBehavior.
👎It's not always easy to subclass and extend.
👎Easy to abuse with many singletons and have limited flexibility in your codebase.
✅Do I recommend Singletons? Well, it depends...
✅Is your project small? Do you have time constraints? Will your class change in the future, or will it most likely always behave the same? e.g. logging system.
✅Singletons are not the cleanest or most flexible system, but they are convenient and quick to implement.
✅In Unity, Singleton MonoBehaviors can swap instances depending on what scene or prefab is loaded.
🚀Beware overuse, understand the limitations, and use it at your own discretion.
➡️Follow @mefirstgames for more game dev tips.
➡️Free Unity Tools: https://www.mefirstgames.com/hierarchy-comments.html
Getting started, you'll need to download Steamworks API.
📌 Steamworks provides everything you need to create Steam Leaderboards, Stats, and Achievements.
📌 You can also set up the Steam leaderboards in the Steam dashboard, but Steamworks also empowers the game to create a leaderboard itself.
📌 Steam supports persistent leaderboards that are automatically ordered.
📌 Updating a leaderboard is as simple as uploading your own personal score.
📌 Each Steamwork title can create up to 10,000 leaderboards!
📌 A leaderboard has no cap on the number of players that can be entered.
📌 In Barrel Blast, I let the game will automatically create a leaderboard if it doesn't exist.
📌 This means I don't have to manually create a leaderboard for each of the 300 levels.
📌 I can instead, create a new level, play it, and a leaderboard for that level just magically appears 🧙♂️
📌 Downloading the leaderboard is straight forward. Provide the name, the range, and asynchronously retrieve entries for that leaderboard.
📌 Setting up the UI is the trickiest part of the whole process. Cheap tools exist in the Asset Store for displaying a leaderboard.
📌 To manually show the leaderboard, set up a new UI prefab, and write a controller that will spawn a row for each entry in the leaderboard.
📌 It can display information like ranking, name, score, and other user data attached to the score.
✅ Follow @mefirstgames
💻 FREE Dev Tools → https://www.mefirstgames.com/hierarchy-comments.html
📌 Any GameObject can be tagged as EditorOnly.
📌 EditorOnly GameObjects are automatically removed when you make a build of your game.
📌 This means you can have GameObjects that only exist when developing and debugging your game in the Unity Editor.
📌 EditorOnly is great if you want to draw a waypoint or path of an enemy in the Editor.
📌 It allows you to add debug visuals and markup data to your scene without worrying about any performance cost for your actual builds.
📌 When combined with Gizmos, EditorOnly adds to your ability to customize the Unity Editor to maximize your game development efficiency and potential.
✅Get FREE Unity Tools → https://www.mefirstgames.com/hierarchy-comments.html
As a professional game developer, you'll frequently find yourself working inside prefabs that are complicated or that were created by other people.
📌 Unity offers little to no support for documenting your prefabs. This is a huge deficiency when working in larger teams, where multiple people will touch a single prefab over a long duration of time.
📌 Some point out you can add documentation to external sources like a Google Doc. But this is inconvenient, easy to forget, and error-prone for updating.
📌 Imagine NOT being able to comment your code in the file, but instead having to add every comment to a Google Doc instead. This would be a disaster.
📌 The best documentation is in the code. And the best documentation is in the prefab.
📌 So how do we do this and how do we do it without a performance cost?
📌 I've created an editor script that allows you to comment directly inside your prefab or scene.
📌 Anything starting with the prefix "//" will automatically highlight as green, giving you a visual line break.
📌 Don't worry about performance, because these comments are automatically tagged as EditorOnly. This means Unity will strip these game objects out of builds.
📌 There are other Unity tools that do this, but they always add ugly backgrounds and messy color schemes. My tool is lightweight, performant, and allows you to easily document your prefabs and scenes without any fuss.
📌 Documentation standards do apply, and you want to make sure your comments are short, clean, and convey useful information.
📌 Simple, straight forward, and performant, I hope this tool helps your development process in small and large teams.
Download Free Here
Input is an essential part of your game.
📌 Unity just made the Input System a verified package.
📌 The Legacy Input system has always been a pain. With a convoluted setup, developers could find themselves copying input code everywhere when their design wasn't well planned.
📌 Players can now define a series of input actions inside an ActionMap. Individual ActionMaps may be used to control the player, a vehicle, or specialized UI views.
📌 Individual Actions may be mapped to specific input bindings from different devices. This abstracts away the details of what the input binding is firing. Now your game can just check the actions.
📌 Schemes represent different control setups. This is good for device types, like Keyboard&Mouse vs Gamepad.
📌 Your Input settings can easily be exported into an auto-generated C# file. This gives you access to the polling or subscribing to the actions for any given ActionMap.
⭐️ The addition of the Input System was long overdue. The ease of use and modular design of the new system allows you to focus on what really matters, your game.
Meet STU 😈
✅ Potential Game Name: STU - Adventure of Bit
💻 Hi everyone! This is a fantastic clip of the new game I'm working on. Currently in the experimental design and pre-alpha stages. I'm targeting a short story-driven game with unique characters in the digital world.
STU stands for
* Self Aware
* Turing Complete
* Universal Program
🎮 STU is the first truly self-aware artificial intelligence every created. Vast and comprehension, STU's system extend multiple machines across the web. Currently, in conflict with humans, STU creates Bit to assist with the humans.
😈 STU may come off rude and condescending, but STU does not do so intentionally. STU views Bit and humans as inferior, similar to how humans may view a colony of ants. The fact they work together and create amazing colonies is impressive, but when push comes to shove, they can only affect us as a pest.
Me First Games is an independent game studio dedicated to creating unique and bizarre video games.
Star Impact is an upcoming adventure platformer coming to PC, Mac, and Linux.
Copyright (c) 2020 Me First LLC