Copyright (c) 2020 Me First LLC
YOU must decide how to architect levels when you're developing your game.
Whether it's using a scene, prefab, or implementing a custom format for each level, it is not always clear what is the best approach.
📌 Before we begin, let's clarify that there is never a one fits all rule. As an effective game developer, you must look at your circumstances and make your own design decisions.
🚀 Scenes Using a different scene for each level is a classic solution. Before nested prefabs were a thing, a scene could be additively loaded and contain only game objects for the specific level. Unity allows for asynchronously (kind-of) scene loading. However, there is extra overhead that is included in scenes that is not necessary if you're additive loading, e.g. lighting data. Games that are not pushing the performance limit can still use this technique and never have issues.
🧠 Prefabs Using prefabs for levels is now extremely easy and straight forward. A level prefab can nest other prefabs inside of it, e.g. You can place your SlimyBadGuy prefab inside your level. Although the prefab editor is powerful, sometimes it can be flakey or confusing on what values are overridden or applied. Pro tip: set up a scene as your prefab editor environment so your level will appear as it would in-game. With prefabs, you also don't need to worry about referencing objects across scenes. Beware referencing all prefabs from your main scene and having all prefabs and dependent resources loaded into memory.
🚀 Custom Format This should not be your default solution, however, it's great if you are randomly generating the level data or allowing your players to edit or build their own levels. It may also be required depending on your performance requirements; with a custom solution, you can implement true asynchronous level loading where each object in your level is instantiated in different frames.
⭐️ Whatever you decide make sure it works for you and your skill set, performance, and scheduling requirements.
⭐️ Follow https://www.instagram.com/mefirstgames/
📌 You can hit the ground running and quickly prototype or build small projects.
📌 Excellent cross-development support. Constantly updating build pipelines is a thing of the past.
📌 It has 2D and 3D support for graphics, lighting, and physics.
📌 Unity uses C#, a programming language with fairly high-level concepts, making it easier on noobs.
📌 The Asset Store is full of tools that you can use or at least use as a baseline.
📌 The online community is active and it's common to find answers to questions online.
📌 Unity has long term support, constantly fixes issues, and are planning major new features.
📌 Mobile friendly: the much-improved engine now runs fairly well on mobile devices.
📌 You can get it FREE if you're a student or looking to learn game development.
📌 Animations, particles, physics, and common game systems are built directly into the engine.
📌 Straight forward Editor UI and multiple IDE support.
⭐️ Unity is a great engine for indie and small games. If interested, it's worth a try.
💬 Leave a comment below: What do you like about Unity?
🚀 Like and repost for a friend for part 2:
😂 Every coder has been confronted by someone with a "life-changing" app idea. "Build this for me," they say. Although it can be annoying, you must understand that these people are cursed. They lack the ability, skill, and will to build or even spearhead the development of their own ideas. As a coder, you are at the forefront of turning ideas into reality.
🧠 You get to practice problem-solving. The sad truth is that the majority of people who go through school never learn the skill of problem-solving. Instead, they memorize facts, dates, and blindly accept the opinions of other people and take them on as their own. Problem-solving is a special thing, it gives you the ability to build and make a change, whether it's in software or the real world.
🤑 You have power in the market. In an ever-advancing world, a good coder is hard to come by. You'll have the power to say no to a job, acquire work in almost any city, and often have the ability to negotiate relocation packages. Just make sure you continually hone your skills as you fend off the frenzy of recruiters.
🚀 There are many more reasons to become a coder and we'll explore those in the future. If you want to learn or master coding, then you'll require practice. The sheer amount of hours you must put in to learn the concepts depends on your circumstance. In the world of Software Development, there are no excuses. It either works or it does not.
🔥 I'm Miller from @mefirstgames and we make games for me and you.
Dependency Injection (DI) is a design pattern in which an object receives other objects that it depends on.
A class doesn't know where it's dependencies came from and doesn't even need to pass dependencies to any child objects it creates.
⭐️ There are four roles an object may play in Dependency Injection.
📌 Service - The dependency or object to be used.
📌 Client - The object that is using and depending on the service.
📌 Interface - Defines how the client can use the service.
📌 Injector - The object responsible for constructing the services and injecting them into the client.
⭐️ If you're confused, no worries, here are examples of all the roles
📌 Service - Class Retriever, implements the IDog interface.
📌 Client - Class Walk, requires an IDog object.
📌 Interface - IDog, defines the methods for all Dogs.
📌 Injector - MyInjector, creates the correct type of dog and injects it.
⭐️ The power behind this design pattern is the loose coupling architecture.
💻 We could easily create a new type of dog, Pug, inject it, and the Walk class will work fine.
💻 Passing dependencies as arguments are no longer required.
💻 All dependency logic is offloaded into Injectors, allowing Dog to focus on being a dog.
💻 DI allows for factories to be injected also.
➡️ There is sometimes a performance cost depending on the implementation.
➡️ DI assets exist for Unity, we'll be covering this soon.
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
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