Search Unity

Book “Learning C# 7 By Developing Games with Unity 2017 - Third Edition”

Discussion in 'Community Learning & Teaching' started by packtpub, Jan 15, 2018.

  1. packtpub

    packtpub

    Joined:
    Oct 27, 2016
    Posts:
    44



    This book “Learning C# 7 By Developing Games with Unity 2017 - Third Edition” by Micael DaGraca & Greg Lukosek (Dec 2017) helps develop interactive 2D and 3D platformer game by learning the fundamentals of C#

    Start with the basics to get started with C# 7 and its latest features. Then see how to use C# 7 and its latest functional programming capabilities to create amazing games with Unity 2017.

    Create C# script for Unity, add objects into it, and learn how to create game elements with them. Then work with the latest functional programming features of C# and how to leverage them for great game scripting.

    Throughout the book, learn to use the new Unity 2017 2D tool set and create an interactive 2D game with it. Make enemies appear to challenge your player, and go through some optimization techniques to ensure great game performance. At the end, the 2D game will be transformed into 3D, and be able to skill up to become a pro C# programmer with Unity 2017!

    What You Will Learn:
    1. Learn C# 7 using new features like tuples, variables, and non-nullable reference types while building games

    2. Understand the fundamentals of variables, methods, and code syntax in C#

    3. Use loops and collections efficiently in Unity to reduce the amount of code

    4. Develop a game using the object-oriented programming principles

    5. Implement simple enemy characters into the game to learn point to point movement and Tree behaviors

    6. Avoid performance mistakes by implementing different optimization techniques

    7. Export 3D models and 3D animations and import them inside a Unity project

    8. With your new knowledge of coding, you will be able to look at Unity's Scripting Reference code examples with confidence
    Author Bio: Micael DaGraca

    Micael DaGraça is a game designer and AR/VR developer living in Porto, Portugal. Micael grew up playing video games, and that passion never went away. So, later on in his life, he decided to learn how to create games. Without any previous knowledge in coding or 3D animation, he slowly started to create simple games, learning each time more with those experiences.

    Micael works for other studios, helping others to develop their game ideas, and has also integrated into a company that focuses on the creation of interactive apps for health and well-being purposes.

    Greg Lukosek

    Greg completed his mechanical engineering diploma at ZSTiO Meritum— Siemianowice Slaskie, Poland. He has learned all his programming skills through determination and hard work at home. He started work as a 3D artist and drifted away from programming for some years. During his career as a 3D artist, he discovered Unity and adopted it for an interactive visualizations project. At that very moment, he started programming again.

    Greg ditched his 3D artist career and came back to writing code professionally. He is now doing what he really wanted to do since he was 8 years old—developing games.
     
  2. Azmyk6000

    Azmyk6000

    Joined:
    Aug 14, 2017
    Posts:
    1
    Hello, I am currently going through this book and so far it has been very useful.
    However, I can not find a Forum on Packt website to go over the problems that I run into.
    At the moment I am stuck on Chapter 10, pg 164 where it says to "Import KillTrigger.unitypackage" into my project.
    I have downloaded the file from the Packt website for this book and so far KillTrigger.unitypackage does not exist to import.
    Please help.
    Is there a Packt forum for their books?


    * edit: Through the Packt Errata reporting feature the Author has fixed this omission. Thank you!
     
    Last edited: Apr 15, 2018
  3. AstralEQ

    AstralEQ

    Joined:
    Oct 26, 2017
    Posts:
    3
    I got this book as part of "Humble Book Bundle: Game Development by Packt" This book starts out great. There are 15 chapters. I am currently on the 12th. The first chapters about Variables, Methods, Lists, Objects and such are a good learning experience. It's when you start getting into actual game making that it becomes more than a little complicated, and if this one game doesn't work, that's it...you can't just move on a couple chapters to the next game and hope you learn something. It doesn't completely fall flat, but it's getting there for me.

    For a book format, where you can write and write and write, and teach and teach, this one feels like it starts to get "phoned in". If you missed a sentence, you could get lost. Sometimes you even have to refer to the code at the end of the chapter just to see the *actual code that was skipped over*. There is also the problem of the assets. It's as if someone just packed up the game (where a file for a chapter seemed to be from 2-3 chapters after the one you're on) and threw it in the zip file. Game development is about problem solving. If you can't take the time to figure things out, what's the point of starting, right? Well, when you're a beginner and need the hand-holding, not even being asked to, but rather being thrown into the mess of having to use files that might not be named the same as the author mentions, might contain extra prefabs that you don't need (the files you're going to learn to create might already be in the package you're being asked to load, without mention of not importing half the file. It's as if the author isn't the one that packaged these files, and that's very unfortunate for the student. Supposedly there are reviewers and hopefully someone who actually tests these books. This one shouldn't have been released in its state) doesn't help one bit, it just creates frustration.

    Like I said, chapter 1-7 were fine. They were learning, with small code "projects" (A bunch of "Hello World" stuff with sending info to the console) I learned a lot from these, and even took what I learned and made something more complicated and it worked. Proud moment there. But...

    Chapter 8 - The "Concept" shows a map of a level I would've liked to make. It looks like a Mario Bros. level. I'm sure I'd learn some things if this was the level we were going to created. It is not. The rest of this chapter is just concepts we'll hopefully learn.

    Chapter 9 - The book is about coding. I get that. But this introduction (and reliance on) the x.unitypackage files is where things start to slide downhill. Because they are not always what you need. It's lucky the author chose to show a copy of their "player.Unitypackage" file because the one in the CH9CODE folder contains what looks like the *entire list of scripts* I would go on to learn to write in the next 4-5 chapters: Camerafollow, Collectable, Enemy, GameManager, KillTrigger, LeaveTrigger, LevelGenerator, LevelPiece, PlayerController, triggerMovement, and ViewInGame. Quite a preview there. It's a good thing I understood enough to uncheck these scripts and not blindly import them into my game or I'd have to just delete them (and I'd get errors because all the Inspector stuff wouldn't be plugged in). I imagine there are some readers that simply clicked import and found themselves in a minor bit of trouble. Materials: "Player.physicsMaterial2D" was missing from the package file.

    We learn we'll be making an auto-run game, rather than moving a character around on our own, which I felt was lazy. I figured from the concept I'd be making Mario Bros. not Mario Run. The character auto-runs in a direction, which just leads to problems later (like its low jump height chosen by the author). Learning about ray-casting and animating was good stuff, though. As I go further in the book, I learn things, but also reach points of frustration that I quit for the night. If things worked in this book + files package, I should've been able to finish all this in a couple days.

    Chapter 10 - Game Manager: This was an important chapter and I'm glad to have read it. Learning about the Game Manager and game states is probably one of the most important things you can do in Unity (and whatever other programming language will support the concept), but again with the loading of things instead of simply teaching again. It's like a teacher handing out a sheet of paper with the math problems already solved, and says "look this over and hand it back in, I'll pretend to give you an A, I'm such a good teacher you'll all pass this class". "Using triggers" asks you to load a prefab of a KillTrigger ...trigger. Oops, there isn't one in the CH10CODE folder (following the same pattern as I started in Chapter 9 with CH9CODE), it's in the project folder. Okay, found it. Inside is the prefab I find "KillTrigger" and...KillTrigger script, the file I don't need because I'm going to learn to write it myself. Again with the figuring out what not to include. What is KillTrigger.prefab? It's a simple object that I should've been simply *taught* to make instead of given to me. I think it's basically an empty object with a 2D box collider added (and set to be a trigger), given a Sprite Renderer (so I can see it while testing?) and then we'll attached a script to it. Making these "region" items, it would've been nice to be taught this rather than given it, so that I'd know how to make my own later. The hill is getting steeper. Using triggers should've been Making triggers.

    Chapter 11 - The Game Level. Oh boy. This might've made a good you tube video, because then we could see what the writer decided to show instead of tell. The Creating a Designed Level felt like it could've been exactly what someone who got this book to learn to develop games would like to go into more detail about. The difference between designed and generated levels. Okay. Shown a couple pictures, taught something about making the ground that you'll probably just end up importing in later anyway. And...then it ends so abruptly it's like the teacher told everyone to do something, but didn't teach how and sat at his desk working on his and then showed the whole class after they sat there confused for a half hour not knowing what to do. You're shown that same "concept level" as before and already I know with the 6f jump height there's no way that level would work. But that's fine because the teacher is simply showing his completed work with no explanation. And then it gets even lazier in the teaching. Since we're making a "Run" game (at least it wasn't Flappy Bird), we go right into the "generated levels". I didn't feel like procedural generation was something a beginner should start with (in a book that starts by trying to cure your "Scriptophobia", and assumes you have no experience scripting), but okay.

    Creating a Generated Level is where the book starts to fall apart. You're still learning something, but you feel like you've been promised more. More importing of files that are broken or bloated is going to lead to confusing of "why is my whole level just one straight floor?" or "why am I learning to fix someone else's files just to learn from them? what else have they failed to teach me". The teaching is average, he doesn't know when writing this that someone is going to sabotage the files when he asks you to import them, but then again, we come to a conclusion that it would've been a LOT easier and a lot more useful to be TAUGHT how to make a prefab of a GENERATED LEVEL (emphasizing, not yelling here) PIECE that to be simply told to import a file. I'm supposed to be learning here. Yes, it's a coding book. Learning C#. But the second part of that title is "developing games" (well, some of one game). You taught me how to import a floor (would've been a good short lesson on how to make the object instead of just importing it), never how to instead import a texture and turn it into a floor. Then you could've taught me how to arrange the floor, duplicate, arrange another floor, test for jumping, add the Kill Trigger item (which I should've learned to make instead of importing), then CREATE an exit point, and CREATE a start point...and an exit trigger. And them make sure they're all the child of an object or something so I could save it as a prefab (I remember this from somewhere else, definately not here) Instead of I'm just importing prefabs and expected to understand them, and here go again with more broken files...

    "Download and import LevelPieceBasic.unitypackage into your project. You will notice that the PlayerPieceBasic.prefab has been imported into the prefabs folder". No, it hasn't. LevelPieceBasic contains LevelPieceBasic.prefab. Is this the wrong file or is it just named wrong? Oh look, all the scripts are in the prefab again, uncheck those.

    Later in the chapter we start writing a "LevelGenerator" script. You're shown lines 1 to 17, then 30 to 53. This is another moment where it's good the code is at the end of the chapter so you can see what was missed (these books have editors and reviewers, right? You don't just ship them out without testing? I mean, people pay for physical copies that will never get updated). This is actually kind of funny, because you're "taught" the code to AddPiece(). Then you're asked to test the game, and it doesn't work. Congratulations! Wait, what? The lines that are left out in the book are:

    void Start()
    {
    GenerateInitialPieces()
    }

    public void GeneratorInitialPieces()
    {
    for (int i=0; i<2; i++)
    {
    AddPiece();
    }
    }


    The author assumes everything went correctly. The picture of Inspector shows the Level Prefabs size at 1 with just the LevelPieceBasic plugged in. Nothing actually happens because all we did was create a method we don't even call. If not for the end of the chapter code, I wouldn't know what to do here (without loading up a script from the chapter files...I'm supposed to be learning, not checking the answers). But we're not at the end of the chapter, we're still going, assuming that everything worked.

    It would've been helpful again to be taught to make a level prefab (I think I know how, I think I could do it on my own, but there are no specifics taught, it's almost assumed I go off and make 2-3 more to inject into the Level Prefabs). I can't find it but I remember at some point the author created 2 more (steps and hole) prefabs to load into his game because those can be found in the Chapter_11 folder. So, of course I loaded those in thinking "cool, I'll just load these in and"....fix them. They're broken. No, they aren't so much broken as they contain all the scripts again that have nothing to do with them. So, uncheck those. And now the pieces don't have scripts attached to them, so I went into the prefab and attached KillTrigger to the (invisible) KillTrigger, and LeaveTrigger to Leave Trigger...and then notice that all the box colliders are shifted up to the right, as if someone went in and added "1.36" and "-.55" to their offsets. I'm not sure if the ExitPoint is in the right spot or if that's also shifted over because I wasn't really taught enough on how to make these prefabs, just what they look like. (My character has 0 chance of making those jumps)

    Ya know what would've been useful in a book about Learning C# by using Unity? How to write a CameraFollow script to follow a 2D character in the game view. Probably would've learned some good stuff about cameras and vectors and framerate in maybe 20 lines of code. Instead, we imported a file, were told to snap it into the inspector and moved on to the next chapter. For a book that'd rather focus on coding and less on other things, it doesn't always want to teach the coding either.


    And this is about how far I've gotten so far because the next chapter, where you're importing buttons that don't look like the buttons the author is using (Green to go, red to stop...but the lights are blue and orange. What do I do?)...and you can only assume things are going work since they aren't yet. I don't know if I'm going to continue with this book or move onto "Mastering Unity 2017 Game Development with C#" and hope I've learned enough to keep up with that author. All that book says I need is Unity 2017 (I've got 2018) and the "determination to succeed". Hopefully I've got enough left over after this book. I'm sure the authors went in with good intentions, and maybe all the code actually works with the files they created on their own without showing me how. But the state it's in digitally...it's a mess. This thread was posted in January, I got the bundle in October, so I'd hope they have gotten feedback and fixed things but they obviously didn't. At least I got it cheap as part of the bundle (there plenty of other stuff that justified the purchase). I did learn a lot so far, and I'm inspired to continue on with Unity again, but I'll probably have to learn about collectables [sic], enemies and "tree behavior" from someone else. Maybe it's my fault, maybe I didn't go in without the prerequisite knowledge or experience to use this particular book, but it still feels unfinished and could've gone into more detail on things. I'd recommend the first 1-7 chapters to an absolute beginner, the rest I feel might be too frustrating with the file problems. There are some you tube channels that would teach a lot more, and not cost $34.