The beauty of Abstract Classes (in my opinion) is the possibility of implementing different behaviours in it's Children Classes (or Derived), very similar to the case of a Contract (using Interfaces)... but with the difference that we are allowed to have Class Fields (i.e.: member variables). That's a cool thing about Abstract Classes, because with Interfaces we can just list Methods, not Fields.
@nerusongear Жыл бұрын
Well, getters and setters would be your fields in the interfaces but not private 😅
@jeffmccloud905 Жыл бұрын
public fields are strongly discouraged in C# (literally in the C# documentation since the year 2000). it's tragic that Unity encourages this pattern.
@alec_almartson Жыл бұрын
@@nerusongear Sure, with Interfaces you can predefine Methods, even Getters and Setters. That's fine. On the other hand, in Abstract Classes you can use Protected Fields to derive them to any 'children' classes. For instance: In an Abstract Class you might use Fields, such as: [SerializedField] protected float _myVariable; With a Getter/ Setter (or a Property Accesor) you would be apllying the Best practice ('by the book'). Btw Unity does not really encourage using Public Fields in Classes (although youcan see it in the Unity documentation, yes, that's true. Those examples should be rewritten)... that Bad Practice is encouraged in most of the (paid and free) Beginner's Courses you find everywhere in the Web (I won't mention any names, but I can say that Jason Weimann and Code Monkey are the only two mentors that I have seen to follow the "Right Practice" of using [SerializedField] private.... Even ChatGPT is writing code with everything as "public". It's up to us to learn to identify that as a mistake, and not to replicate it in your own code (because it exposes our variables to other classes... you don't necessarily want that, which will surely confuse other programmers and yourself in the long run).
@jamesknecht Жыл бұрын
As someone who works at a non-game dev job with little free time to game dev I appreciate short to the point videos like this as it leaves more time to actually try it out. I like this short format for topics like this, but I would prefer the usual longer videos for how to do bigger picture things that require two or more topics.
@TChrisBaker Жыл бұрын
Knowing when to use abstract and when you use interface is always a little tricky. I think that's inheritance vs composition, correct?
@Unity3dCollege Жыл бұрын
Yea i'd say generally prefer an interface until you see yourself copy/pasting code or want to be able to assign them somewhere in the inspector. Since you can only have 1, it's a bigger commitment than an interface.
@TChrisBaker Жыл бұрын
@@Unity3dCollege your courses actually helped me learn interfaces and now that's my first instinct for a solution
@andersmartensson8659 Жыл бұрын
The video was good, short and to the point. But I think that in todays society, rambling has it's place. It could be something that you encountered, use case that was good or not good it slows down the pace a bit, but can still provide useful information. It also gives videos more "meat on the bones" a sense of being present sometimes. Not simply cold hard facts. Bones are great, without them you would just be a pile that hardly could do anything, but without the meat you wouldn't be able to do anything at all. So my preference is "more meat" (that is more "ramblings"), coming from an experienced person it is most often worth the time. You might perhaps not recognize it at the time, but it is good to have heard for the future, most of the time. :)
@TheKarishi Жыл бұрын
Abstract classes, and inheritance at large, is such a godsend for avoiding repeat code. Drawing up an inheritance tree that shows GameObject -> Item -> Equipment -> Weapon -> Sword -> Blade of Darkness and explains the logic of putting it together - that sense of putting certain methods at certain layers where you know they'll get used by everything that inherits, and then adding methods with increased specificity as you continue to inherit.
@rambii. Жыл бұрын
I used them a lot in my RPG project for items, and a character abstract class for NPCs and players that has the common stuff like health, movement speed, etc. And common functions
@saschacontes2305 Жыл бұрын
Great video, guess I have to watch it at least 3 times (while taking notes) to grasp all the valuable content. Thank you
@nomore6167 Жыл бұрын
I'm been re-watching from 0:52 to 1:10 repeatedly for the past 10 minutes and I still can't understand it. I don't have any experience in Unity or game development, but I am an old programmer by trade, so it's not like this stuff is completely foreign to me. The problem is that your wording doesn't seem to make sense to me. Here's the problematic part: "...then in our code that uses the items, _we reference the Item base class that OnTriggerEnter2D adds the items that we touch to our inventory_, and our inventory code doesn't care what type of item we're using." I understand the underlying principle/big picture, but my brain cannot parse that statement. It seems as if the word "that" between "we reference the Item base class" and "OnTriggerEnter2D adds..." is the problem, which could potentially indicate this was originally a longer sentence and you missed cutting the word "that" while editing.
@badscotsman Жыл бұрын
I'm not sure if this helps, but this part "... and our inventory code doesn't care what type of item we're using..." refers to polymorphism (which I'm sure Jason left out because it further adds to the cognitive load of the video).
@arkonza Жыл бұрын
Quite succinct, I think it will serve as a good introduction to those who are not overly familiar with abstract classes. There's the added benefit of highlighting an example of when interfaces would be more appropriate, and I find this helps bridge the gap for a fair amount of people who are self taught and still struggling to see the usefulness of interfaces. Perfect length to get people talking and and asking questions, and that discourse could give an indication if a longer video on the topic is needed to focus on certain areas.
@Gaguera Жыл бұрын
I am implementing the usage of Items right now, what a great timing! thank you so much!
@11sveden12 Жыл бұрын
Thank you for including the pitfalls and when NOT to use this. That information is equally as important!
@universalequalitypro Жыл бұрын
Honestly, I like your slightly longer format videos more. When you "ramble" you give some really good ideas to beginning and intermediate coders that haven't been introduced to some of the issues or idea that come with time and experience. This video seemed to be missing some of the meat of the topic of your other informational videos. I've been watching for years and I've gained a lot of really good coding knowledge and wisdom from you. Bottom line, this video is a bit too short for the topic.
@Daeniak Жыл бұрын
It's really well explained, I always loved your content for that, everything is always explained with examples ! Thank you for taking your time to help us !
@matteosberna735 Жыл бұрын
I have a "unit" class that I used as a store for every parameter a unit has (health, armour, etc) and later I implemented moving units that also has have other stats (speed, etc) and ofc these stats, albeit unused,are present also for my non movable units. do you recommend using an abstract class? An interface? Note: this class is used by some other scripts (health, movement, a specialized turret script) to gather the unit stats
@lineofdeparture3584 Жыл бұрын
Wondering if his course is also suitable to learn 2d turn based strategy games? Somebody know?
@ltweed1 Жыл бұрын
Great overview/summary. Since you just covered this in the bootcamp, I already understood the subject, so I'm probably not the best person to say whether it was too short. As mentioned earlier, I do find the production a little distracting (even though I thought it was well done)
@dbweb.creative Жыл бұрын
The thing that sucks is that interfaces cannot be serialized in inspector. Also can put child class objects in a list by its parent class type, but C# pretends it knows nothing about methods or properties on the said objects that come from child class(unless you cast to it)
@gamerscreed83257 ай бұрын
I have some troops in my project and i'm deploying them as a user. so I've three different key features for the troops 1. Troop Type(Ground, Air) which would be an abstract class and will define the core logic for the movement for both types 2. Troop target (multiple) it would be an interface and a "Has a" relation so i can make it for multiple targets and can implement multiple targets for the same troop 3. Attack type(close ranged, long ranged) which would also be an abstract class so my troop attack class will inherit from this abstract class and will have multiple targets and troop movement claas will inherit from the movement class...... So now is my approach is good or too complex for no reason or any other flaws? can you suggest something
@KaanErayAKAY Жыл бұрын
Hey Jason great video. Can you make a video about related with Scene Management. I mean when should we create new scenes. Yes it depends to game but there isn't any clear video about that.
@KHodow Жыл бұрын
Good video! Abstract classes and interfaces are great!
@lonaur Жыл бұрын
Video length is good and the content is presented very well as always. Great way to use the arrows to point to the mentioned parts of the code. Still have to say that I don´t like all this stock footage video at the start. I love the outro and seeing you. So I guess the intro should be you as well.
@miransheix3351 Жыл бұрын
hello, can you please make a video about texture cutter destruction the way that rainbow six use for wall destruction plsssssssssssssssss
@brainovergames7790 Жыл бұрын
I have purchased your master architecture course & completed it BUT haven't received certification. Pinged you over discord & mails multiple times but still no response. Will you provide certification or not?
@Unity3dCollege Жыл бұрын
Sorry, they should be working now. Let me find that email and track down what's going on. Will send a direct link to the certificates in there
@Unity3dCollege Жыл бұрын
I can't find your email. Can you resend it to Jason @ game . Courses and let me know here when undo? Wanna make sure they're not getting rejected or something by gmail
@bhuvneetsaggu4011 Жыл бұрын
i just ignore the your video even its ranking 1st on abstract classes because of thumbnail, after wasting half an hour on youtube, I noticed it your name on top. thanks
@restushlogic5794 Жыл бұрын
I hope DOTS can use abstraction and reference. Right now, abstraction, polymorphism, inheritance, and others have no useful when build fully implement DOTS game.
@ahmedfireplus Жыл бұрын
Well, how did you get into my account? But your channel is nice, I will subscribe
@sinistermephisto65 Жыл бұрын
Why is youtube over stimuatling these days. I think we could talk about abstract classes without all the holywood right?
@Unity3dCollege Жыл бұрын
I'd like to think so, but it seems like whenever i show code for more than 10 seconds, everyone stops watching.
@TChrisBaker Жыл бұрын
Yeah I agree maybe I'm just getting old but I kinda like the dry information 😂
@ltweed1 Жыл бұрын
I kind of liked the "hollywood", but it *is* distracting to be sure. Maybe tone it down a bit.
@morkgork3060 Жыл бұрын
Thank you.
@dynamicvoltage97653 ай бұрын
Imagine thinking this simplifies code lol
@Johan-rm6ec Жыл бұрын
No it's not helpful at all like dozens of other KZbin tutorialists video's. Video is a hook for selling an expensive course. Sat to see a whole generation of wannabe game programmers learning not really something valuable. Nice revenue model.