Комментарии:
What is a struct?
ОтветитьI thought that components need to be separate "things" that are added to a game object and we can see them via inspector. The bullet checks for a component and finds the interface IDamageable even though the object does not have the script added in a way that we can see it on the inspector.
Is Monobehaviour also a component then?
i could watch this video 100 times and not understand what the point of this is
ОтветитьSo it’s like a Base class that can call the function that it’s child uses without having to declare the child class itself?
ОтветитьExcellent, was slightly puzzled by Interfaces and with your clear explanation it now makes sense.
ОтветитьI started really few days ago and every topic I watched , really nice explanation and simple examples.Thank you for prepared these .
Ответитьfunfact: if you watch this at 1.25x speed it sound like his newer tutorials :D
Ответитьthat is insanely op, i could dodge so much code overhead xdd
ОтветитьJust to say thanks and tell you, this way of teaching is really good for many reasons, not only explain the definition but also showing a real case scenario and after watching and searching other videos, this one is still the best one and easiest to understand, i do have watched your explanation about events and also delegates, but i forgot it sometimes and keeps coming back, so just want to say thanks for all the works you do, and i hope you found your success in your current project, and also i want to ask about planning for the future, any new paid course in udemy, i really wondering how to create the chart in your blueprint steam game, and how to manage those data, I've tried to make something similar but ended up a mess, i knew you are busy these days, and yeah I'm just mainly want to say thanks. 😅
ОтветитьGreat Video, i only have one Question. Why do you use the TestInterface Method with the Interface as a parameter and not use: myClass.TestFunction() ?
ОтветитьThis was very helpful, thank you.
ОтветитьIf i have pistol and i call damage () and it take 30 damage and i have sniper if i called damage it take same damage should i make function like this damage ( damage amount) to make each one take different damage?
ОтветитьIs the interface only there to say that you have to implement the functions from the inherented interface(giving error message)?
ОтветитьThank's a LOT for this video!!! 👍
ОтветитьWow 🤩 ❤
Ответитьcódigo mono
ОтветитьGreat video. Does unity support a C# version now that allows interface method implementations?
Ответитьbecause i have try multiple times to learn Interfaces we not luck do you able to shared the Interfaces codes to my ?
Ответить/Z'({mvk(F'')shld M'''tx(XADT''')RvkxL'''(VARs mrkz')HUD/s dbl Lt'})/
/> CRTS' ROKtts' TRPDZOS' ++- X'-ZWTTS' battel'Plaa'Tz' || iWVxchmz'''/
/> int= cg AVN'''BZ' KOVS' VOLX'(tM''') RMZ'- 1/
Interfaces look so easy to implement, I'm definitely gonna use them more and write cleaner code with them.
ОтветитьEvery other tutorial explains them as just a contract that does nothing. Thank you for explaining an actual use case.
ОтветитьSometimes with your tutorials I watch like "What's he doing? Why are you writing it like that?? What the hell even is-OHHHHHHHH SHIT"
ОтветитьI've never implemented interfaces in Unity (but I do use an awful lot of protocols in Swift, same thing, different names).
I'm wondering tho, what are some technical advantages and disadvantages of interfaces vs delegates?
In my case, I have a class called TakeDamage, which has a delegated event called takeDamage, then everything that could be damaged, for example a script called health for most NPCs include the TakeDamage component and then subscribe to the takeDamage event, or for a breakable barrel, I do the same, add the component and subscribe to it.
Then I just need to check if there's a TakeDamage component and call its function to take damage.
So other than having to manage subscriptions manually, is there an advantage/disadvantage compared to implementing interfaces?
To help understand the concept of interfaces:
Interfaces are like middlemen for class dependencies. You don't have to worry about breaking dependencies when you change or switch out a class it depends on as long as it implements the same interface. The dependency just needs to know how to use the interface to get what it needs. It doesn't care how that output is produced as long as it works. When a class has implemented an interface, you know what methods to expect from it and if you ever delete one of the methods it will throw an error to ensure the agreed upon methods are being used (errors are caught immediately at the source instead of at runtime wondering what happened).
Analogy:
A DVD player and a blue ray player work differently yet expose the same interface (play, stop, fast forward, etc.). This way, the user doesn't have to know what is going on inside the machine. As long as they understand the interface, they can get the desired output (the video). This way they can switch out a DVD with a blue ray player and still get what they want.
Found this channel, I am exited to learn new consepts. Seems like this guy is quite good about explainign things, I am sure it is not easy task to explaing how to write a code for a some codemonkey like myself XD
ОтветитьHi! I would like to know if there are any differences between using interfaces vs a generic component that implements UnityEvents that I can attach to any GameObject that requires that system or function.
For example, I made a generic Health component with a public TakeDamage() method that triggers a UnityEvent whenever damage is received, and it also triggers another one when it reaches zero health. This way I can reuse it in any other GameObject that requires the exact same health system and implement their own unique behavior by subscribing to the onDamageReceived and onDeath UnityEvents.
I found this method simple to understand, implement, reuse and modify, but I wonder if there are any performance or architecture advantages by using interfaces.
I would highly appreciate if anyone could clear this out.
Cheers!
the interface is confusing no matter how many videos i show and not matter how trying to the have stuff that makes 0 sense to my
ther only way this system looks useful for the example you show is if you wand to open doors and colse the lights ect in few words the use or interact with the environment
because from what i understand what Interfaces do its to apply the fraction (the void) the have those contacts and to work no matter for how many the are
the have multiple problem's wean some use Interfaces for players health though at least in the example you show me
1. the damages is predefined that is terrible for helth system,
in most cases including the game im try to create the have multiple damage sources and each damage have the own values and the own way to dealing damage,
for example not every weapon in my game dealing the same damage and not every damage in my game is on trigger enter
2. why to use interface to dealing predefined damages and limit your self with all thos contracts,
instead to add on the on wean the bullets enter to dealing this predefined damage ?
in my opinion at least in the example you show me interface is not necessary and created health system with predefined is terrible idea
Could you do an update to this video using the charp 8 default implementations please? I am trying to figure out how they work and how they can be used but im struggling atm :)
ОтветитьSo this is kinda like generics for classes?
Ответитьi have fear to learn interfaces but when i watch your video then its gone, and i also started to loving interfaces as well as your flow of teaching that, thank you so much sir
Ответитьwell with only 1 function in the interface it's easy - you just call that function. What if it has 3, 5, 10 functions and you have to implement them all?
ОтветитьWith interfaces it isn't even "inherit" anyway, you implement interfaces, not inherit from them. C# is still only a single inheritance language, but it allows you to get around this limitation with it by implementing multiple interfaces.
ОтветитьFor the first 9 minutes of the video I was clueless of what was happening. Wondering why would I even use this or how. Then you started the example and it clicked. This is exactly what I was looking for. Thanks
ОтветитьI love this video. As a game artist trying to learn C# I need to see how my code works and what it is capable of, the example with the 3 different objects truly creates an Aha moment in my brain!
ОтветитьOi, good example of usage of an Interface.
This "GetComponent" method, is that a pattern or something? I like how how this plug-in method works. Has it been covered on this channel?
Cheers!
Hi there, i just love how simple and fast with all of your tutorial, until this i got my unity studies done smoothly thanks to you, but when i try to put a Interface file to any GameObject it just say that i cant put abstract class onto it, is this new Unity feature now? i did search on google but there arent any topic about it, thanks alot!!
Ответитьjust cool, into the unity, nice!🙌🏼
Ответитьbest video ever on interfaces ,thank youuuuuuuuuuuuuu
ОтветитьI spent the last 2 hours searching the web for how to see if an object contains a interface of a particular type similar to what you showed except through ray casting. After watching your video I confirmed I was executing my code correctly and it should have been working the way I thought it would have (for example being able to do TryGetComponent<IInteractable>) When it didn't work I thought maybe you cant do that since its not the classes direct name but you confirmed my thought that you can. Then I noticed it was because I had a box collider on the object and not a box collider 2D. (Im making a 2D game) And that's how I wasted 2 hrs of my life.
ОтветитьU BEST!!!
Ответитьbeautiful, thanks
ОтветитьMlk, se pá que o canal foi hackeado
ОтветитьThank you!!!!!!!!!!!!
ОтветитьInterfaces still elude me. Couldn't you just use a regular class and on bullet hit, get a reference to what collider you hit and then call gameObject.Damage() if the function exists?
Ответитьvery cool feature
ОтветитьC#
- White background
- "Function" instead of "Method"
- K&R bracket formatting.
What?!
Thanks!
Ответить