How You Can Easily Make Your Code Simpler in Godot 4

preview_player
Показать описание
In this video we look at Inheritance vs Composition and a scenario where Composition is preferable in Godot 4.

Both Inheritance and Composition have their pros and cons, but Inheritance is for more often taught, despite Composition being very important in Game Development. I recently ran into Composition in my own projects and felt that it was vastly underrated and deserved to be taught.

Chapters:
00:00 Intro
00:27 Inheritance Approach
01:57 Composition Approach
03:06 Setting up the Components
04:53 Using the Components
06:01 Creating Example Objects
06:44 Outro
Рекомендации по теме
Комментарии
Автор

came here from Brackeys and so glad i did, GREAT video. loving where the game Dev world is going, feels like a new era that is far more enclusive than ever before

rohanflanagan
Автор

I love that you managed to explain a fairly confusing and complicated topic with examples showing both the problem and the solution by using this approach and also the tradeoff for using the inheritance over composition ( at least for this kind of scenario ). I think those are the kind of educational videos that are hard to come by, especially with an easy to follow visual representation, which are really appreciated by the community. We know it's not easy and it takes time to find examples and then explain them in a simpler manner, as you did, but we really appreciate each one of them and we thank you for that!

pietricele
Автор

This really clicked for me, the animations were super helpful to visualize abstract ideas and I really appreciate the walkthrough in the end

the_kryllic
Автор

cool video! if you are already trying to decouple code using composition over inheritence, i would probably create a signal on the hitbox that the parent object would connect to. then whenever the hitbox gets hit, it emits the signal, the parent can then decide what to do with it. in this case propogate the attack info onto the health component. this way the hitbox component does not need to know anything about the health component.

fkeyzuwu
Автор

This has to be one of the most (if not the most) approachable explanation of inheritance vs. composition. Very easy, straight forward and clear. I had to learn it the hard way and for the longest time couldn't understand the advantage. I wish I had this video back then. Love it!

capsey_
Автор

Composition as a design pattern I think is uniquely equipped for solving problems and making more robust (and easier to maintain) code. There aren't a lot of videos on programming patterns in Godot and seeing this is great. Talking about general/generic problem solving I think helps beginners out a lot by helping us step outside of "How to do X" to thinking about breakdown solutions to fit their own needs/program. Tutorials have their place and purpose of course, but I think Godot (programming in general to be honest) is in great need of this sort of problem solving/design thinking sort of information. Great video!

computersciencestudentriverbat
Автор

This clicked for me. Was trying to learn this topic and you explained it so well in such a quick but well paced manner, never stop teaching, this was amazing

GhostbitStudios
Автор

I really like how clearly and concisely you described the two strategies and how composition can be a preferable way of organizing your code. I look forward to more videos from you!

AndrewWooldridge
Автор

Hey, so glad I found this channel. I love how you visualize these concepts and make it easy to understand. looking forward to see more of these videos. Keep it up!

MrMelonMonkey
Автор

Loved the simplicity that you found to explain an not so simple subject with easy to follow examples. Thanks for bringing this one!!!

Uriann
Автор

Your tutorials are so good. There's plenty of beginner tutorials for Godot at this point, but we are seriously lacking in simple guides on how to architecture games. Tutorials like these are incredibly valuable and many budding game devs wont even know that they need to be looking for this kind of stuff. Please keep making tutorials!

Haxses.
Автор

These videos are invaluable, man. I've come back to these several times now as quick refreshers as I'm still learning everything. Truly great

SamuTheFrog
Автор

Hey, you did excellent explaining the difference between Inheritance and Composition. Not a lot of videos take the time to utilize simple illustrations (and color coding elements such as Attack, Health, and Hitbox). Very helpful for visual learners. You're on the right track, and I hope you keep making videos. That said, I'll be sending this video to my aspiring game-dev friends when I see them inevitably copy/paste code. Also, that sprite animation at the end is super cute!

alectriciti
Автор

Bro, you need to continue this type of videos. I'm really learning from this. <3

scollll
Автор

Man you are easily the most clear and efficient teacher I've found for game dev / Godot on YouTube. Hope to see more videos. Thanks for the help.

cm
Автор

Coming from Unity where you can throw multiple scripts on things without thinking or use multiple inheritance, this kind of helps me get my head around how Godot is 'meant' to be used! Good tutorial.

travotravo
Автор

Great video, not only displays composition trumps inheritance in a lot of cases (inheritance has it's use cases) but also ties into how the workflow in Godot is awesome with it's Nodes system.

HonestGameDev
Автор

When I develop in Godot, I often use a mixture between inheritance and composition, and oftentimes, I use resources instead of nodes for composition since it is easier to modify through an export statement.
For example, I have a slew of statemachine resources that I can plug in to my Actor class (which is basically an entity class), which makes it easier to trade behaviors depending on the entity type and whether there is currently a cutscene or battle.

lunaticwyrm
Автор

Damn, just found out about your channel and you do a very good job explaining these kind of topics (classes, inheritance vs composition). The Godot community needs more content creators like you

Kantrul
Автор

The first video I found on this topic was the epitome of the "Every programming tutorial" meme video, but your video made everything click in my head immediately! Thank you so much for explaining composition in a quick and easy-to-understand way!

flunk