This was a PERFECT explanation of interfaces and their use cases. These concepts seperate hobbyists from professionals. Your way of tutoring is great. You could do a tutorial on object pooling, and how it is used to avoid Instantiating and Destroying objects!! ( I will always recommend new things for you to teach, since I think more people can understand you on these complex concepts) Great work again!
@JamesMakesGamesYT2 жыл бұрын
Thanks for the recommendations, appreciate it!
@brettabraham2 жыл бұрын
Simple, straight to the point, but chock FULL of good information. Interfaces was one of those things I "planned to learn one day" but now, I feel so much more confident. Great video!
@saseb10602 жыл бұрын
finally a video that has an easy and direct example and not something abstract
@JamesMakesGamesYT2 жыл бұрын
Glad you found the video useful!
@GlitchyMF2 жыл бұрын
Ok... I spent like 30 minutes trying to understand it but finally.... I get it, instead of checking if its an enemy target and if it is then hitting this enemy target, then if destructible cover then breaking it, then explosive barrel then exploding it.... It just checks if its something damageable then does damage to it, and specifying what the damage does in the objects script itself.... That my friend..... Is GENIUS... I was always afraid of coding because... Deep in my heart... I knew it was hard and needed alot of memorising (which isn't good for a student) but now i realised.... It just needs understanding
@Keanine2 жыл бұрын
I already knew what an interface could do, but I wasn't totally sure of the use case for it compared to a base class or an abstract class so I'm glad you added that last part that cleared it up!
@moeingharib68572 ай бұрын
this was the most comprehensive, simple and useful video I've seen in months..
@JamesMakesGamesYT2 ай бұрын
Thanks for the kind words, glad this video was helpful
@monkeyrobotsinc.9875 Жыл бұрын
this is by far the best tutorial on Interfaces I've ever seen. ive watched dozens of them, and none of them break it down so simply and especially show a before and after example. really helpful to see. thank you very much.
@JamesMakesGamesYT Жыл бұрын
Thanks for the kind words, I might try to do some more content on interfaces in the future
@junaidywijaya2 жыл бұрын
This is by far the easiest to understand tutorial about interfaces i found online, thank you so much..
@lcb5651 Жыл бұрын
I've finally found a place that explain so clearly a very fundamental use case, I never fully understood this until I found this video, thank you very much for this.
@JamesMakesGamesYT Жыл бұрын
Thank you for the kind words, I’m glad the video helped!
@RetroVemVideos2 жыл бұрын
Very well put together, you respect your viewer's time and explain plain and simple the concept and give a good example, no BS. Great job!
@linksys86542 жыл бұрын
been programing for almost 10 yrs and just know understand what interface does. thanks
@johnnyfatsacks5209 Жыл бұрын
I never fully understood interfaces and this perfectly explains it. Thanks.
@foreducation408 Жыл бұрын
one of the best tutorial I have ever seen on interfaces in unity.
@thedrumminggamer1064 Жыл бұрын
this was an amazing explanation, i already used and fully understood interfaces, but this helps increase the Modularity of code , which decreases time to add new features, and removes dependency within code , which can then further be boosted by the observer method
@Fuudo_123 Жыл бұрын
Learned quite a bit just from about 4 mins, can already see which parts to use interfaces for which is great, thanks man
@scull3208 Жыл бұрын
I can't express how much this 4 minute video has helped me. Thanks so much!
@thedude1102 жыл бұрын
Cheers, mate! I really enjoy how you take fairly complex concepts and explain them in a very simple way
@vaibhavjaiswal7992 жыл бұрын
Suddenly interfaces seems easy, really good explanation
@AtomicDurpYT5 ай бұрын
I can't begin to tell you how much this has helped me, Thank you.
@JamesMakesGamesYT4 ай бұрын
I’m glad this video helped you!
@lucas8089 Жыл бұрын
Very good explanation. This video alone made my Unity skills go from 3/10 to 7/10. This is what I've not been doing
@JamesMakesGamesYT Жыл бұрын
That's a great testimonial! :D Glad the video helped you!
@tomasroch49052 жыл бұрын
Personally I consider your videos the best of unity learning videos. I absolutely love them for how short and understandable they are, yet they are filled with valuable information. I wish you the best luck in making videos like that
@JamesMakesGamesYT2 жыл бұрын
Thanks for the kind words! I've taken a bit of a break from KZbin but I'm working on more videos for the future!
@davdav4804 Жыл бұрын
Your channel is so good and underrated, thanks you, this was the best explanation I found on interfaces and it helps me a lot to learn game dev !
@jean-michel.houbre2 жыл бұрын
Very clear and very well illustrated. I'm lucky to have subscribed!
@IlaiyaBharathi2 жыл бұрын
Thank you!!!!!!!!! You are a blessing for the game dev community!!! I finally understood interface and you made it look so easy….. thank you thank you
@JamesMakesGamesYT2 жыл бұрын
Glad the video was helpful!
@Stromhammar2 жыл бұрын
Great explanation! I had worked with interfaces in the past without even realizing it, and now It all makes sense
@FyresGames Жыл бұрын
Yup I use a lot of Interfaces. Just my day night cycles system. use 3-4 different interfaces to control sun, moon, time, clocks, lights, etc. Even got a custom extension to find interfaces. For enemies. Mostly got IDamagable, IKnockable, IStunable.
@junaidywijaya2 жыл бұрын
Most tutorial i found only show how to create the interfaces but not showing what it can really do and what is the benefit of using it, but this one is make it clear and show exactly what it can do, once you explaining about damaging in firstperson script, it make me realize how powerful interfaces can be if we know how to use it Edit : can you teach about event, action and delegates for next ? These are also a little bit tricky to understand,
@JamesMakesGamesYT2 жыл бұрын
Glad the video helped and thank you for the suggestions!
@aurabeth1680 Жыл бұрын
Very helpful and gave the WHY and HOW in a very digestible way. Thank you!
@zanagi5 ай бұрын
wow i was almost going crazy trying to understand from other source. thank you so much
@jarrettonions3392 Жыл бұрын
Thank you. Implemented... wow.. so much easier than the jumble i was working with. Great, consise, easy to follow tuturial.. and exaclty what i wanted and how i wanted it to work. Damage ammount on the thing that actually does the damage... then health on the thing that actually looses health... so simple.. no of these weird incorrectly placed and refenenced tangles
@overyonderstudios97792 жыл бұрын
This channel is great, subscribed. You've hit a great niche with videos for people who are finding themselves stuck and need a fresh approach. Would love to see a video about structuring projects. One thing that I get stuck on all the time is feeling like I need to refactor my codebase because I didn't architect it well from the beginning. Even if I've used the right design pattern for something (if I really believe that a singleton is the right way to handle some functionality) it bugs me when I end up with all my scritps lumped together inside a generic "scripts" folder. Should I structure my project based on pattern? (e.g. singleton folder, observer folder, interfaces folder, etc.) Or subject? (e.g. items folder, characters folder, enemies folder, puzzles folder) Or type? (e.g. prefabs, materials, textures, animations) Hard to decide!
@petteriblomqvist8309 Жыл бұрын
Huh. Interfaces aren't a new concept for me, but the way you managed to cram all relevant information about them into couple minutes just made everything click and suddenly I feel like I actually know how, when and why to use them for anything. Informative presentation, sticks to the topic, good pacing (a bit fast if the concept is all new and/or English isn't your native language, maybe). Overall verdict: Subbed.
@JamesMakesGamesYT Жыл бұрын
Thanks! I'm glad the video was helpful
@LuzuVlogsGamer Жыл бұрын
This was soo well made I would of believed you if you said that you worked for Unity :O
@fen4flo Жыл бұрын
Wow this really opened my eye to so much more possebillities. Thanks
@williamwan188 Жыл бұрын
Super short and clean tutorial. Thanks very much.
@dreamisover98132 жыл бұрын
Short, and explains the problem as well as the solution very well!
@JamesMakesGamesYT2 жыл бұрын
Glad the video was helpful!
@Liforus1 Жыл бұрын
The best explanation of interfaces. Thank you so much!
@JamesMakesGamesYT Жыл бұрын
Thanks! Glad the video was helpful!
@theemeraldend430211 ай бұрын
Thank you, I am currently making something where the player can move in 2d, but needs to interact with stuff and need something that allows them to interact with a button without knowing what the interactable object does
@HansonJ9 ай бұрын
GetComponent can retrieve Interfaces? I thought it could only grab actual components, makes the name misleading.
@DisturbedNeo3 ай бұрын
Initially, it did only retrieve components, specifically anything that inherited from UnityEngine.Component, hence the name. But in 2014, the method was updated to take better advantage of C#'s generics, and now it can retrieve any type that is, inherits from, or implements the target type. The name has remained the same for backwards compatibility reasons.
@SalarianStudios10 ай бұрын
damn such a great explanaition. definetely deserves a sub. thank you so much man :D
@Mannavard882 ай бұрын
Thank you, very clean and useful explanation with examples
@monkeyrobotsinc.9875 Жыл бұрын
btw just a tip: id slow down your talking a bit since your accent is pretty rough, and your voice is already kind of low in volume (try adding compression). i play all your videos at .75 speed and subs enabled, but still struggle to hear and understand you. im only trying to help because your content is very good. please keep it up.
@JamesMakesGamesYT Жыл бұрын
Thanks, I appreciate the feedback! Pacing my speech is something I'm trying to work on
@okee2 жыл бұрын
Short, quick, and helpful
@dontthinktoomuch7152 Жыл бұрын
The best tutorials i've ever seen
@Wishbone_Games8 ай бұрын
This saved my life
@darkmattergamesofficial Жыл бұрын
This is incredibly helpful. Thank you!
@FreyaAndMe2 жыл бұрын
Great video. Thank you (tiny bit slower to reduce pauses and moving backwards will be really nice if possible)
@JamesMakesGamesYT2 жыл бұрын
Thanks for the tip! Pacing is something I'm trying to get better at with my videos, so really appreciate the feedback
@omar-00824 ай бұрын
thanks you so much but i have a dumb question, can I add multiple functions into one interface or i must avoid that? Anyway tanks you very much !
@Eculeus007 Жыл бұрын
If you want differnts damages so make this: public interface IDamageable { void Damage(float physicalDamage, float magicalDamage = 0f) } burnDamage , poisonDamage , how you like. Declare attributes for your Weapon. (PhysicalDamage, MagicalDamage) and use damageable.Damage(weapon.physic, weapon.magic) or only damageable.Damage( 0f, weapon.magic)
@Sciaining4 ай бұрын
Thank you for this tutorial, it was really helpful! Though this makes me wonder: is the interface only accessible to the script that defined it or is it accessible from any script? And if it isn't, how can I for example make an object damageable by different objects (and not just the player)?
@JamesMakesGamesYT4 ай бұрын
You can get an interface from any script using the GetComponent() method. The method is accessible on all game objects so you can call it on a collider if you raycast or collide with an object for example
@Sciaining4 ай бұрын
@@JamesMakesGamesYT Thanks!
@pistolerointergalactico90197 ай бұрын
Perfectly explained fast and clear
@der-Dritte7 ай бұрын
Better than offical unity video
@SelaMalka2 жыл бұрын
Amazing video, thank you so much! Subscribed!
@haliesnailie45419 ай бұрын
this video explains interfaces better than my college classes lol
@MaskedImposter Жыл бұрын
Interfaces are cool but I keep struggling to find a use case in my projects. I'm wondering if they might help in my buff system though... I'll need to review the code when I get the chance.
@AraragiAriel2 жыл бұрын
Awesome! Answered exactly what I wanted to know
@JamesMakesGamesYT2 жыл бұрын
So glad to hear that! Hope this can help you with your game dev project
@AlexBlackfrost2 жыл бұрын
"Nice one, James!"
@angel_machariel Жыл бұрын
Excellent example. Question: If an object is many things, such as IDamagable, IEnumerable, IPersistent, IWhateverable, IFlyable, ISwimable, then how would one go about that design wise? Surely deriving from many Interfaces must be a flawed approach?
@JamesMakesGamesYT Жыл бұрын
Great question! Deriving from multiple interfaces isn't a bad design in itself, but it can lead to your class having too many responsibilities. For example, we could have a PlayerController class that implements IDamageable, IHealable, IFlyable and ISwimmable There's nothing wrong with implementing many interfaces likes this, but if your class gets too big, then it may make sense to split the class up based on the their concepts. In the above example we could split PlayerController into a PlayerHealth class that implements IDamageable and IHealable (the concept of adding and removing health) and PlayerMovement that implements IFlyable and ISwimmable (the concept of movement) I hope this answered your question
@angel_machariel Жыл бұрын
@@JamesMakesGamesYT Oh wow, this makes sense to me. Thanks for taking your time to answer!
@TripleCreeper3 Жыл бұрын
i understand it now, you are a beast
@TheNbc272 жыл бұрын
Hello, I am trying to troubleshoot what seemingly should be a simple problem, but unfortunately I definitely didn't structure my scripts properly. It involves player skins, and addressables. What defines a local reference in unity? I asked a more in depth question elsewhere, and I was essentially told that all my local references would break, and then was told if it was prefab references they "should" break. I believe it was a typo and he meant wouldn't break. Thank you for any help!
@tyb.c.4332 Жыл бұрын
Gonna get my alt account to like this twice, great video!!
@klubis4935 Жыл бұрын
Just what i was looking for
@risingdagger54169 ай бұрын
this is good but how do i check if the collision is not in play, because I'm using a boolean in my code to check if the enemy is grounded or not using this interface method
@ikelos8190 Жыл бұрын
could you also use composition (of classes) for some of these problems right?
@JPsonicACE7 ай бұрын
that was really usefull and clear , im just not sure .. where do you write the Interface - > public Interface Idamageable { void damage(amount) }
@JamesMakesGamesYT4 ай бұрын
You can create an interface in a new file like you would creating a new script
@minimastudios_Ай бұрын
Hey james! So im making a game where you can pick stuff up, and then place it in a storage box. I made an iinteractable with a pickup method, and then an icontainable to place it in the storage, it kinda feels like maybe not the right way to go about it for this use case but maybe i just havent figured it out well enough, any advice if this is a right use case?
@johnsartain4160 Жыл бұрын
I'm still not sure if I need to be using interfaces or a base class on my current project
@hernandonj2 жыл бұрын
Awesome video. Thank you!
@JamesMakesGamesYT2 жыл бұрын
Thanks Hernando!
@thedragonlegend61922 жыл бұрын
just to be sure do write your interface in a new script or in the case of the shooting game for example in the shooting game youi made would it be on your caracter script ?
@JamesMakesGamesYT2 жыл бұрын
Good question! I prefer to define an interface in its own script file because I see it as a separate concept that can be used across different scripts
@nightyonetwothree2 жыл бұрын
I have tendency to use interfaces' names like ICanDoSomething or IHaveSomething (GetSomethingFunc/property), as I+able sounds as it's a target of an outer action. How bad these practice is?
@rubenbarrosogarcia6114 ай бұрын
Amazing explanation
@JamesMakesGamesYT4 ай бұрын
Glad it was helpful!
@_ace552 жыл бұрын
Hey, could you make a Video about "base classes" (mentioned at 3:13)
@JamesMakesGamesYT2 жыл бұрын
Thanks for the suggestion, I can look into it! Anything in particular you'd hope to understand better in the video?
@_ace552 жыл бұрын
@@JamesMakesGamesYT I'm relatively new so I don't know what base classes are at all! So what they are, how to use them properly and an example would be awesome!
@farrukhkamal2315 Жыл бұрын
thats very nice. ima use it
@joshgilderdale992 жыл бұрын
Awesome information here
@irondolphin1559 Жыл бұрын
I just dont get how you can get the component of an interface when you cant put interfaces on gameobjects? Wouldnt your code technically look for an interface that isn't there
@irondolphin1559 Жыл бұрын
I mean if its finite as in no mono behavior of course.
@xKingRognarx2 жыл бұрын
That was really helpfull, thanks a lot :D
@fv4202x10 ай бұрын
I could do this with sub classes. Interfaces just makes things a little bit longer. Then why are they exist? I never felt like I really need interfaces.
@erikberg28939 ай бұрын
He goes over that in the video. You're only able to inherit from one class. What if you want to give your class more functionality after the you you make the subclass to work with another system you already have in place?
@fv4202x9 ай бұрын
@@erikberg2893 I changed my mind thank you
@galileemason8813 Жыл бұрын
great work !
@BFBStudio7 ай бұрын
Great Video!
@GUYX10 Жыл бұрын
Thank you :)
@JayadevHaddadi2 жыл бұрын
genius ❤️
@zekiozdemir4202 жыл бұрын
thank you
@JamesMakesGamesYT2 жыл бұрын
You’re welcome! Hope this helps you with your game project!
@lee1davis1 Жыл бұрын
The problem I see with interfaces is that they disregard the DRY principle.
@JamesMakesGamesYT Жыл бұрын
Interesting, in what way?
@lucasgrd42582 жыл бұрын
alright take my sub
@Johan-rm6ec10 ай бұрын
Thank you for not using the word C.O.N.T.R.A.C.T. once!!!!
@simoncote40647 ай бұрын
he did tho twice XD at 2:30
@JamesMakesGamesYT4 ай бұрын
I actually like the contract analogy but I think it gets misused. When you write up a contract with someone, for example a plumber, the contract doesn’t say “you will be a plumber” it says “you will do the following plumbing tasks” Again it comes back to the “what you are” vs “what you do” example from the video
@sayankabir79582 жыл бұрын
great video. although i think i need to watch it 5 times more to understand properly 🙃
@watercat1248 Жыл бұрын
If understand correctly this inderfece method let you do something like damage for example Without need call spefic tag or script to do calling other script ECT if this inderfece method do what I thought the do you are live saver because before today I have plan to make multiple codes for damage the Player because in my game I have multiple damage source If understand correctly with this method I'm able to make the health for example IDamag and in my weapon damage output and I'm done not more work needs script the call other script and ECT I still I have not understand all the details but if the works in the way I understand is very useful thenks And no I didn't even know this inderfece system existed before today so never used before Ther is one thing I don't understand yet for Idamage method wean someone create health system the need input and output because not every object able to get damage and object take damage and object do damage can you able for example if the bullet touch the enemy Player lose 20 HP how the helth know that able to get damage for the IDamag ? And how the bullet able to know that when the tuch the enemy the do -20 HP ? For example I understand this method happeneds wean ever it's possible but still Can't you explain this topic to my What I'm trying to say is that the helth case like for example I tell you the one sure try to do damage in every area the able to do and the other get damage I need some way to combine those methods
@testservicesssss2 жыл бұрын
bad practise use -able, IDamagable bad interface. An INTERFACE in C# is a type definition similar to a class, except that it purely represents a contract between an object and its user. It can neither be directly instantiated as an object, nor can data members be defined. So, an interface is nothing but a collection of method and property declarations. The following defines a simple interface:
@fleabag6312 жыл бұрын
Good video. I am currently using gameObject.SendMessage when I need to call common behaviours across different scripts (like the example in the video). What are the advantages of using interfaces over SendMessage? I can think of a few, such as messages not having return values (you get around that by sending a reference of the message sender) or the limitations on parameters (1 only, although you can send a class). Interfaces probably faster too, as SendMessage is a quite slow (usually not a problem if you use it sparingly). For those not aware, SendMessage allows you to call any function by it's name that is on any script on a gameObject. For example, in the Shoot script after the raycast you could call hitInfo.collider.gameObject.SendMessage("Damage", weaponDamage). Any shootable object has a Damage(float weaponDamage) function. Non shootable objects (like terrain) can just not have the Damage function and SendMessage will do nothing except use some CPU time (as long as you don't set the flag to send an error).
@JamesMakesGamesYT2 жыл бұрын
Great question! I haven't worked with SendMessage but from before, but based on your description here's the difference I can see: You know there is a dependency between your current script and another script because you're calling damage on it using SendMessage. The interface approach makes that dependency explicit and more obvious whereas SendMessage hides it. The other issue you may have is if you change the name of the Damage method or the type of its parameters. In the case the code will compile and run, but the damage logic won't work correctly and it'll make it harder to track down the cause. In a real world example, imagine you need to tell your neighbour that his car is blocking your driveway. The SendMessage approach is you shouting at him from your window and hoping he can hear you. The interface method is knocking on his door and telling him directly. Hope this helps!
@antro_phagus5 күн бұрын
This was very easy to understand and it helped me a lot, thank you!!
@richie495610 ай бұрын
This might seem like a stupid question, but what are you doing in this line? EnemyTarget target = hitInfo.collider.GetCompoment(); is this a way to create an instance of a variable from another class? What is is required to do this? I understand the rat cast part I am actually only confused about the declaration of target
@PUNCHLER4 ай бұрын
i think he is caching the target object to make his life easier