Thank you for this tutorial. In a way, we can replace interfaces with scriptableObjects. What is the best method in your opinion?
@ThomasBCharlie3 жыл бұрын
As a self-taught programmer and game dev enthusiast I find that nearly all Unity tutorials completely gloss over any semblance of proper design patterns. They cock up quick scripts that do what their title says in sub-optimal ways and are impossible to expand and build upon. For years, such tutorials have been teaching me to haphazardly connect various Unity components and just hope for the best, and as a result I continue to rewrite my code over and over while struggling to make anything more complicated than the simplest Space Invaders knock off. Nowadays, I find these kinds of tutorials that actually talk about how code is written in in general much more useful than anything else. Being set in Unity helps a lot too, cause I'm not familiar with many frameworks outside of that. Thank you.
@HATL2012 жыл бұрын
That's comparing apples to oranges. Most of the Unity tutorials on youtube are teaching you how to implement a certain game logic. And yes, they should be quick and concise, telling you exactly how to implement that logic and be done with it. On the other hand, code design patterns, principles and practices is a separate domain, and it's the responsibility of the user to learn them as well as the game logic on their own.
@buriedomasta33752 жыл бұрын
@@HATL201 where do I start from? I am a beginner
@nuin9937 Жыл бұрын
@@buriedomasta3375 how did it go
@beardordie53085 жыл бұрын
For those struggling to use the selection manager outside of this or any project with it already working, here's a hard-earned tip: make sure your camera has a Physics Raycaster component on it.
@InfallibleCode5 жыл бұрын
Thanks for sharing this! I definitely glossed over this very important detail lol
@gadgetboyplaysmc4 жыл бұрын
Go up and save the day you foo! LIKES LIKES LIEKS!!!
@potatomilk74004 жыл бұрын
and tag said camera as Main Camera. I almost had an aneurysm trying to figure out why it wouldn't work for me.
@al20ov874 жыл бұрын
I don't have that on my camera and it still works fine
@kidsteveee5 жыл бұрын
Oh man, we need more tutorials like this.
@InfallibleCode5 жыл бұрын
More content is in the works! Stay tuned! :D
@KHam564 жыл бұрын
I much preferred this teaching style of your videos over the mock conversations of the current videos. its faster to the content without the bloat of expression, "story building" filler moments like showing off gameplay, and the greeting conversation. time is precious and videos like this feel much more efficient and attention holding.
@TheGuyWithTheLemon5 жыл бұрын
Dude this is a great tutorial! Finally, a channel that goes in-depth into core coding principles that every game programmer should be following! Coming from a coding background this level of detail is perfect!
@JackEatock3 жыл бұрын
As a student, I can't explain how useful your videos are at improving my code. Love your channel!
@n8dev3 жыл бұрын
honestly this is the most helpful tutorial I have ever watched
@InfallibleCode3 жыл бұрын
Wow I really appreciate that!
@n8dev3 жыл бұрын
@@InfallibleCode wow that was quick, I appreciate you making these tutorials so much! I am going to link your video on namespaces in my next devlog, it helped me organize my project really well. With Brackeys gone, I can see you blowing up as much as he did :)
@InfallibleCode3 жыл бұрын
@@n8dev I'm just glad that my videos are helpful, that's the most important thing :D
@NeoDragonEWW5 жыл бұрын
I love your tutorials. I like that you take on slightly advanced programming topics, show them in a real-world scenarios/use cases, and explain why the topic makes sense - eg. this video on the SOLID ideas that a lot of teams use.
@InfallibleCode5 жыл бұрын
So glad you found it helpful! I really like tackling these advanced topics because their so important and aren't covered very often.
@gadgetboyplaysmc4 жыл бұрын
I have not even watched the video in full and I'm fucking mindblown.
@THEspindoctor843 жыл бұрын
I didn't really get it, until I saw you swap out one script for the other at the end. Then it clicked...mostly. such a great video, and the production value is off the charts and very much appreciated
@dotaportalvideo4 жыл бұрын
Was not expecting to become a better coder while looking at Unity tutorials today. Nice work.
@snook55555 жыл бұрын
Love code quality tutorials, it's an area I'm always looking to improve in
@krisitak5 жыл бұрын
In this case, instead of interfaces, I'd use abstract classes that inherit from MonoBehaviour. That way you won't have to assume something IS A MonoBehaviour that IMPLEMENTS an interface. Also, some assertions to lock these invariants. Great video, nice editing.
@mayankbhaisora26992 жыл бұрын
Came across your channel a couple of days ago and it’s one of my favourite gamedev channels. Your tutorial easy to understand and you explain everything properly like the real problem, options, solutions. Great work man. Keep helping people like me.. thanks
@themerpheus5 жыл бұрын
Wonderful. Simply wonderful. Good explanation for those of who don't know SOLID principles.
@andrewshandle5 жыл бұрын
Fantastic tutorial. When working in the corporate world, I always try and teach the SOLID principles to developers from day one. There's nothing more demoralizing then coming across legacy code with a 12,000 line method in a class that does 37 things and nobody knows how it works. ;)
@BrokenPuzzle033 жыл бұрын
You have taught me more than my 4 years in University
@InfallibleCode3 жыл бұрын
Wow! That's amazing to hear :D
@KasperSOlesen4 жыл бұрын
All the SOLID principles explained and used in 15 minutes :) Good job.
@bgildersleeve5 жыл бұрын
Excellent tutorial. It's great to see videos like this that emphasize clean code principles!
@lightiichen4 жыл бұрын
This REALLY helps a lot as I'm just getting in designing my own game structure but not able to find a tutorial like this. KEEP IT UP BRO!!!!!!
@MaddinUndSo3 жыл бұрын
this might bring a little bit more organization in my coding. thank you very much!
@shoco24 жыл бұрын
Honestly don't know another channel that explains everything so clearly and understandable, great video man
@ScilexGuitar4 жыл бұрын
Im a beginner and I have no idea what is going on. Maybe I will in a few years. Saving this vid :D
@tapoutluke3 жыл бұрын
Thanks for the video! This helped me make a WeaponManager class allowing for different weapon behaviors :D
@donnyjoe7653 Жыл бұрын
I like how you genuinely want to inform us about green being your favorite color, in a subtle side note 14:04 :D. Thanks for the great content!
@newpractice4 жыл бұрын
this explanation of how scripts should interact with each has been just what I needed, thank you
@018FLP2 жыл бұрын
What a relief! I'm an absolute code beginner, so it's easier for me to separate everything for debugging so i naturally code using something very close to this principle. Though i was dumb for making extra steps, but it's very cool to see this is a good practice. Nice!
@Bergquist3D5 жыл бұрын
Awesome video! I would love to see this turned into Pure ECS!!
@sparrowhawk815 жыл бұрын
Interfaces are nice. A dev partner and I have been working on a simple 2D shmup for about 1.5 years now (we are taking our time). It came in handy for a lot of stuff. We have interfaces like IProjectile that make it so that all our different types of projectiles HAVE to have a damage value, speed, lifetime, etc etc etc. It also comes in handy when using Zenject, which we do ;-)
@InfallibleCode5 жыл бұрын
Good stuff! I always love to hear about practical examples of OOP concepts being applied in game development.
@Osybear5 жыл бұрын
Thanks for concise tutorial. Keep it up man!
@orc_spearman5 жыл бұрын
Very good and easy to understand example, good job and thanks
5 жыл бұрын
Tip for clean code : event handlers should call a function, but not contain implementation. You want to have a quick look at it and understand what is going on, not read throguh the whole event.
@Ohlawdie5 жыл бұрын
Quick, cool, informative - as always Charles! Cheers, much obliged.
@lando65834 жыл бұрын
great tutorial. the community needs more videos like this.
@Walter58502 жыл бұрын
Brilliant! I have been getting back to this video for quite some time, but I just wasn't ready to comprehend the ideas due to lack of knowledge. After reading about SOLID principles on my own and looking through some examples, I was able to familiarize myself with the core ideas. Afterwards, it was far easier to follow the video and I was able to learn much more from watching it.
@Brian-vs9sd5 жыл бұрын
Wow. This is an excellent tutorial on the SOLID principles. The example you used was so relevant not just to game programming but programming in general. Well OOP anyway.
@InfallibleCode5 жыл бұрын
I draw on years of experience building enterprise applications when I work on these tutorials. Some people think that those two worlds wouldn't mix but there's plenty of overlap between business and game development. Software is software at the end of the day.
@myriampaolachangoluisatoap31004 жыл бұрын
Hello, could you post the link of the outline assets you are using? I got 2 errors related to outline script.
@myscipper3 жыл бұрын
It's so beautyful :)
@CCV3345 жыл бұрын
This is exactly what I've been looking for. Thank you so much for the clear and concise example!
@vasikplays88004 жыл бұрын
Hey new subscriber here. Thank you so much. Please keep doing these videos.
@revraitah4 жыл бұрын
Pretty cool and useful tutorial. Keep it up!❤️
@georgew.82823 жыл бұрын
That was one of the most enlightening tutorials I have ever seen. Thank you very much for this!
@orinom41283 жыл бұрын
Your cats tail at the start made me think I had a spider on my screen and i proceeded to spend the next 3 minutes trying to find the spider in my phone
@ananttheant4 жыл бұрын
Thanks for your content, you are my go-to unity related programming Feed!!
@monkeyrobotsinc.98753 жыл бұрын
yep. green is a great color.
@blasder0074 жыл бұрын
amazing tutorial, i like how this is just at the level that i am at programming so i can understand everything , thanks!
@funkyjedi5 жыл бұрын
Brilliant and clear, thank you, looking forward to more in the series.
@mana205 жыл бұрын
Great video, looking forward to more architecture related videos. You should do a series on Event architecture(delgates, events, actions, func) to decouple code.
@BigDaddyGameDev Жыл бұрын
Great video! So many tutorials ignore good programming principles. I have a few bad habits to break.
@hematogen50g4 жыл бұрын
You got my subscription, man!
@InfallibleCode4 жыл бұрын
Awesome, thank you!
@hematogen50g4 жыл бұрын
@@InfallibleCode Got to complete test assignment for Unity programmer job. your channel really helps.
@android2725 жыл бұрын
Thanks for this. I will be using this in my game. I have a class that is equivalent to your selection manager that does way more than what your class did at the beginning of the video. I have a lot of refactoring to do :)
@Sindrijo5 жыл бұрын
Not that it is important to the lessons shown in this video but you could derive from Unitys IPointerEnterHandler and IPointerExitHandler interfaces (in the UnityEngine.EventSystems) instead of implementing your own raycaster. (Note that you do need to add a Physics Raycaster component to your Camera object for it to work, which I saw another comment mentioning but is actually not needed since the code in the video is doing its own raycast.)
@alpho943 жыл бұрын
Great video, but I have a question: it appears how in the update method of the SelectionManager you are first deselecting the object and then, if the raycast hit the object, put the selection back in the same frame. Wouldn't be better to put the select and deleselct methods in a if else statement, checking before the value of the raycast, so that you don't run both and save performance? also since those methods do the same thing, they could be unified by creating a single method which change the material or a value in the case of the outline, as taking it as input paramenter.
@Yulaw2k5 жыл бұрын
Please make more videos like THIS. Do it again with example 2, then example 3. You got alot of views on this. If you check out your spatialOS videos....not many views.... We appreciate your skills as a coder more then you dabbling into the "new".
@InfallibleCode5 жыл бұрын
Haha don’t worry more videos like THIS are definitely on the way. Only one more video left in the SpatialOS series so stay tuned to the channel.
@Yulaw2k5 жыл бұрын
@@InfallibleCode "Celebrates"
@atakankuloglu48772 жыл бұрын
Perfect explanation. Thank you for sharing your knowledge with the community!
@AethernaLuxen4 жыл бұрын
Great tutorial! Btw, captions are broken
@wearwolf42022 жыл бұрын
Your pop up literly was in the way of me seeing what you were doing.... thanks
@michailmarkou19952 жыл бұрын
amazing tutorial!
@modernkennnern4 жыл бұрын
This feels a lot like a Ryder ad :P Really good tutorial though. Certainly got me thinking
@RenatVasetskyi Жыл бұрын
good video, I often have crowded classes that are difficult to expand, fater this video i will try to do everything clearly
@ZoidbergForPresident5 жыл бұрын
Quickie: we could use a List, right? To get outline AND highlight?
@mehmetoguzyardimci85984 жыл бұрын
Quality content!
@NorthernlionLP2 жыл бұрын
Decent video, using so many IDE options instead of just copy-pasting was slightly infuriating tho :p
@endorphingames29572 жыл бұрын
Yes make it more complicated looking at specific IDE functionality rather than copy paste
@daniilparokonnyy79805 жыл бұрын
So useful! Thanks a lot!
@InfallibleCode5 жыл бұрын
Glad you found it useful!
@rutulthakkar92893 жыл бұрын
how is the tag being referenced in the new classes you created from the selectionManager ?
@darkman2373 жыл бұрын
What about using c# events to decouple the code?
@endorphingames29572 жыл бұрын
Yes, I would have a script on each object with the functionality of changing its own material. Selection manager would only sent events on raycast.
@jeffng504 жыл бұрын
I have a few questions: 1. How does the concrete SelectionResponse seep into the code as it just initialises ISelectionResponse the interface? 2. What if I want both effect to manifest? Highlight and outline together?
@JJordanov9454 жыл бұрын
Is there any way we can use both Highlight and Outline Selection Responses simultaneously? I've been playing around with it but as you've mentioned in the vid you have to remove one to place the other. I want to know if I could make a third Response class, say InteractiveSelectionResponse, which is responsible for handling mouse input when you press on a selected object, while still making use of the HighlightSelectionResponse component for visual feedback.
@Daedhal3 жыл бұрын
WHAT ABOUT ADDING A LINK TO THE ASSET USED FOR OUTLINE ?? Edit: After searching for a while, here is the asset used in the video assetstore.unity.com/packages/tools/particles-effects/quick-outline-115488
@turin23 жыл бұрын
Very much appreciated , thanks!
@d11men12342 жыл бұрын
Thank you very much dude
@abwuds72085 жыл бұрын
Great job! Quick question though, why don't you have a Rider warning for the serialized + private fields that don't begin with an underscore?
@lunkums3 жыл бұрын
Hi! awesome tutorial you've created, but i have one question. What is the difference between the deselect and select code bodies? They look identical
@lunkums3 жыл бұрын
nevermind, i didn't see that deselect was default mat and select was highlight mat. Thank you
@Yulaw2k5 жыл бұрын
What about putting any ISelectionResponse as a scriptable Object. Since its only being used by the SelectionManager. You know how an scene object can have alot of components attached to it. Instead of adding another one script to the object, you can drag the selection behavior onto the script using it. Is this a good, or bad idea?
@romeogaming64244 жыл бұрын
Excelent, thanks!
@N0biKn0bi4 жыл бұрын
why do you name some variables with an _ at the beginning?
@TheNamesJT4 жыл бұрын
This is a bit out of my scope of c#, i have an idea though it would be nice if you made a c# basics and intermediate series but to stand out from all the other youtube videos that do this you could make the video like you did in your "Unity Events in Action" and "C# Events in Unity" videos. I like how you incorporated problem solving while also teach code in a in game project. Many many youtube c# series just teach you the basic syntax and read the definition from the documentation and don't show in game examples.
@chrisgreenwell34045 жыл бұрын
Really great , thank you :)
@IronFreee4 жыл бұрын
I wrote my own "selection manager" raycast code a long time ago, I didn't knew there was an already made one. So I never had those limitations...
@coolergappney1943 Жыл бұрын
Can we do videos where we DON'T use weird tools to replace and alter logic. It's hard to follow the process of ACTUALLY structuring when youre making the program do it. I wanna learn something not just copy finished code at the end.
@r1pfake5215 жыл бұрын
The only annoying thing here is that Unity can't serialize interfaces so you can't drag&drop them in the editor. That's why I usually create a abstract base class which also inherits from MonoBehaviour instead (obviously this only works if the class only implements a single "interface", because otherwise it couldn't inherit from multiple abstract classes). It's kinda ugly, but I don't want to lose the drag&drop workflow in the editor.
@-Engineering01-2 жыл бұрын
I think this is a double edged knife. We use these patterns to make the code look more readable but at the same time we're over engineering the code with lot of classes especially for a small hyper casual game where at these patterns maybe never needed.
@magnusm44 жыл бұрын
The problem I have is I try to make my own physics, sort of. I try to make everything come down to one vector3 mainMovement. Then other methods such as SlopeDifference use transform.forward and input. It becomes a cluster**** of variables they use that is shared and changed through the entire script.
@MatheusAugustoGames3 жыл бұрын
I think instead of LSP, you used DIP at around 8:08. I could be wrong.
@asafalroy21593 жыл бұрын
Great tutorial! I have a question though, what would you do if you'd want to combine the two behaviors of the selection responses together, so everytime you hover over a GameObject you'd want to highlight /and/ outline it? Thanks!
@vilinder4 жыл бұрын
I am confused, is the downloadable project one before or after the refactoring is done?
@prudhvi92564 жыл бұрын
thanks for the tutorial, it would have been great if you only used 2/4 of your objects to use the new green highlight methods while having the others still swap to yellow, if that is instead of it would have worked.
@Tofos943 жыл бұрын
i started unity 1 year ago and i tried this tutorial last year. I didnt understand anything :D maaan now i see how messy my code actually is. As a software engineering student in 2. semester i just learned how to code object oriented and with an mvc principle but i feel i cant use these methods in unity/c#
@josephdaniel2354 жыл бұрын
Hello, I know this code is a year old but does this follow the same logic as the one previous? I only ask because the previous code is completely different in this video.
@piotrw33665 жыл бұрын
Hi Charles! Great video! Is making monobehaviour uicontroller an interface a good idea? I wanted to make an interface out of it so maybe pc has different UI than mobile game but if they use the same interface I could just find the interface in Game Manager class and use whatever UI type I get. But can't find a good way to find my UI interface beside var ui = FindObjectsOfType().OfType(). Do you think it's a good way to do it? Thanks!
@piotrw33665 жыл бұрын
Hi Charles! Sorry to bother you but after asking the question I came up with a solution. I get a public GameObject to the uicontroller monobehaviour and use on it GetComponent instead of looping through all the monobehaviour. Do you think it's a good workaround? Thanks!
@madey16853 жыл бұрын
How to change _selectionResponse value at runtime?
@mrduby34644 жыл бұрын
Is there any reason why the shapes don’t have their own script? Is it a best practice to have your raycast script have the material and outline script on it. My first thought while watching this would be to have each shape have the same script that implements the interface and handles all the outlining logic. Therefore each object has a reference to its own material render/outline. Seems like the raycast shouldn’t need to tell the object it’s over to change its outline/material tenderer. It should be referenced and up to the object itself
@endorphingames29572 жыл бұрын
Yes, I would have a script on each object with the functionality of changing its own material. Selection manager would only sent events on raycast.
@Storm35325 жыл бұрын
It's great, but why not just use UnityEvents? This way things will still be nice and decoupled, but much less code (= time) required overall. With UnityEvents, in most cases you won't even need to write a script for a responder, just set what needs to be done directly in the inspector. This flexibility allows to change stuff very fast, which is important in game development.
@Frozthog5 жыл бұрын
Hey Storm! If you don't mind, what would be the steps to replicate the steps in this video but with UnityEvents? I've never really gotten a grasp of unity events and how to use them.
@Storm35325 жыл бұрын
@@FrozthogHi, sorry for the late response, notification hasn't appeared for some reason. If you haven't found it out already: for example, to implement the highlight behaviour, add two UnityEvent fields, onSelect and onDeselect, to the selection manager script, then call onSelect.Invoke() when the selection happens, and onDeselect.Invoke() when it's lost. Now drag the renderer component into the created events in the inspector, then choose Renderer.Material to be set, and assign the materials. Right now I'm actually using a much more versatile solution, UltEvents by Kybernetik, it's free on asset store.
@mrslake70963 жыл бұрын
for prototypes or small projects, I think these principles can be overdone , which means you reduce your productivity & increase code complexity. But I can see how they can be very helpful for larger projects or long term projects
@Laure2full4 жыл бұрын
The code is difrent thant it was last ep did you change it and why?
@dickyerlangga74734 жыл бұрын
thanks for the video, i have followed the instructions based on the video. but i have problem with this error 'The type or namespace "Outline" could not be found (are you missing a using directive or an assembly reference?)'. how to fix it? thanks
@mrduby34644 жыл бұрын
Did you make sure to actually download the Outline pack he said he got off the store? Outline isn’t a native component to Unity so unless you got the same asset off the store Unity has no idea what that is.
@rohith6xt3 жыл бұрын
Does raycast work in augmentation reality
@Robbin_Bob2 жыл бұрын
probably a bit late to this but that syntax highlighting theme you have is amazing, what setup do you have?
@Dohman5 жыл бұрын
Thanks for the captions. / Deaf guy
@happyfarang5 жыл бұрын
Great video. Very solid info. I just wonder, what if you want to make the response conditional, f.ex say, if you looking north make them yellow, if not then use the green outline. Something like that. You would have to make a new class with both interfaces? or am i missing something obvious here? :) I will have to watch this a few times
@InfallibleCode5 жыл бұрын
If you wanted to response to be conditional then you could apply the Null Object pattern. But if you wanted to implement more sophisticated behavior then you'd need to implement a new class to handle it. Does that make sense?
@happyfarang5 жыл бұрын
@@InfallibleCode Makes total sense :) I think i understand it! I will try to make my own test. I like this pattern. The "kind of generic" approach hehe.