No video

How to use Classes in Godot! - Intermediate Tutorial

  Рет қаралды 8,266

Queble

Queble

Күн бұрын

Пікірлер: 37
@buzzbuzz20xx
@buzzbuzz20xx 2 сағат бұрын
This is just a simple and straightforward way of explaining classes and inheritance!
@ched4516
@ched4516 2 ай бұрын
This tutorial was much easier to understand on the specifics without going too far off subject. Keep up the good work.
@user-ni1xg1ok8i
@user-ni1xg1ok8i 11 күн бұрын
this tutorial is really clear and easy to understand. This makes creating classes and using classes to make components very easy to understand. Thank you!
@sebashtioon_
@sebashtioon_ Ай бұрын
Thank you! Very confused about classes before this but now I understand them. ❤
@queblegamedevelopment4143
@queblegamedevelopment4143 Ай бұрын
Awesome, glad I could help!
@xtoo550
@xtoo550 2 күн бұрын
Thank you for this tutorial. I've learnt OOP in university but changing on my own to a Godot proyect is pretty confusing. Keep up the good work!
@kynda
@kynda Ай бұрын
this video is very well explained. I knew how to more or less use classes in c++ but when I saw a couple tutorials of them in godot I couldn't figure out how they worked. thanks to you i think I get it now. your explanation was very clear, subscribed.
@GabeNarwhal
@GabeNarwhal 3 ай бұрын
Your tutorials are hands down the best out there! I have not been able to watch all your videos, but I'm working my way through your videos one by one. If you have not made it yet, I would love a video going in depth on Planes, Normals, dot-function, and all that jazz. With my ADHD, I'm having a really hard time grasping how this works, and I find myself debugging for hours every time I have to calculate distance, angles, and stuff like that. Anyways, thanks for the great videos!
@user-ts3ey5om4b
@user-ts3ey5om4b 3 ай бұрын
Good job,I want to see a video about how to do trade-off between inherit and composition in Godot.
@SoyIbrag
@SoyIbrag 12 күн бұрын
TYSM! Keep up the good work!
@do_it_like_rei
@do_it_like_rei 3 ай бұрын
So amazing that I was literally struggling with this all afternoon, I had like 4 videos up showing how to do it but not as well explained as you. You answered questions I had about this. I'm trying to use it for NPCs (if you'd ever need a topic for a video, please show us how you would go about that :D) Thank you for your video :)
@Danachew
@Danachew 3 ай бұрын
A video on building different custom resources would be awesome!
@lout160
@lout160 3 ай бұрын
I can confirm. This would be undoubtedly awesome. Very necessary.
@fvhaudsilhvdfs
@fvhaudsilhvdfs 3 ай бұрын
we crave another custom resources video :)
@lout160
@lout160 3 ай бұрын
We do. We crave it!
@LouisDoesGames
@LouisDoesGames 14 күн бұрын
nice video thanks a lot!!
@Nishisaki405
@Nishisaki405 Ай бұрын
This was amazing. Thanks a lot
@LouisDoesGames
@LouisDoesGames 14 күн бұрын
at 6:14 you went ahead and made the collision shape unique. out of curiosity. Can't we set the collision shape in the base class to "local to scene" via Shape -> Resource -> Local To Scene?
@AtelicDev
@AtelicDev 2 ай бұрын
Awesome tutorial!
@aahh437
@aahh437 3 ай бұрын
I always get confused on when to use composition or classes in new projects. Could you consider making a video on when to use one over the other (in a generalized manner, or course)? Great tutorial, btw. Although I'm already used to OOP, Godot's python-like language still gets me confused sometimes
@queblegamedevelopment4143
@queblegamedevelopment4143 3 ай бұрын
I'll add that idea to the list! :)
@thegameissimple
@thegameissimple 3 ай бұрын
Use inheritance only when composition is logically impossible. In all other cases prefer composition. And don't inherit deeper than two levels.
@DanielAraujo92
@DanielAraujo92 6 күн бұрын
I just have a question, why didn't you place the code from _set_heatlth into the "take damage" function? When you do health = new_value, wouldn't the function _set_health be called again?
@PhilChilled
@PhilChilled Ай бұрын
What would You say would be better for a game that spawns waves of enemies like a Tower Defense? Using Composition for the Enemy by splitting the health, take damage components or by using an EnemyBase class which will have all of those things. Still quite new to all of this and have been trying out things. If I for example add armor and maybe special abilities to the spawned monsters that would have to be used in the script for the exact monster I am going for but using these two things I mentioned should take care of the heavy lifting? Still trying to see how things work.
@queblegamedevelopment4143
@queblegamedevelopment4143 Ай бұрын
So for the enemies, I'd definitely create an Enemy class to handle all the common functions (like ai, movement, etc.) You could then export properties for things like a Health Component, Stats Component, etc. (all different classes), and these could handle the more composition-oriented logic. Hope this helps!
@lml55
@lml55 19 күн бұрын
please explain inner class omg bro no one on this platform is explaining this one concept
@blazenetic
@blazenetic 3 ай бұрын
Very well done 👍
@lout160
@lout160 3 ай бұрын
I feel like I'm using custom resources wrong or not getting the most out of them. In the game I'm working on, I intended to use them to pass attack data from the attacker to the target, however, I had to resort to using dictionaries instead. I'd really like to see some practical application of custom resources that shows the best use cases and their advantages.
@queblegamedevelopment4143
@queblegamedevelopment4143 3 ай бұрын
Planning on extending this video with a custom resource attack system:)
@Sunflower-lk2xo
@Sunflower-lk2xo 2 ай бұрын
How do you give an instance of a class its own unique variable?
@queblegamedevelopment4143
@queblegamedevelopment4143 2 ай бұрын
Every instance of a class will have the same properties, so to give a class a "unique" property, you either need to inherit the base class (and add new properties), or add metadata
@Ceisri
@Ceisri 2 ай бұрын
so it's just kinda useless...what's point if i can just save a node.tscn with a script on it and attach it to other scenes that needs? cause if there's no difference then classes have no reason to exist.
@H3_remix
@H3_remix 2 ай бұрын
No there’s a multitude of uses for classes, not having to rewrite code is the biggest. If I have ten enemies they can all have the same health. Why create ten scenes with the same script lines written. When code can be reduced it should be. Example, you have a script where you want enemies to spawn every time an enemy dies - you can use a class with a condition statement stating if enemy_dies(): PathSpawn Then no matter the enemy type that died when you kill one it respawns. Then you didn’t have to write the spawn script on ten enemy types. If you plan on having no variety or spaghetti code sure you can ignore classes. If you want to speed up production, have cleaner, more efficient code then use classes.
@Ceisri
@Ceisri 2 ай бұрын
@@H3_remix I have no idea what do you mean by reduced code? How do classes reduce code if it's just another script you instance? Its literally just a script saved as .tscn....same thing as writing a script and attaching it where you need it
@H3_remix
@H3_remix 2 ай бұрын
@@Ceisri you’re missing the fundamental point of classes. If you have ten enemies and they all have 100 health, why would you need to write ten scripts for their health, movement or spawn position. You’re writing much less code because instead od creating ten variables in ten scripts you have one script with one variable. Health. You could then extrapolate it further and add their movement. You can then have their specific mechanics only in their script, but because they’ve inherited the enemy class they don’t need the health variable in each one. Thus you’ve reduced your lines by a minimum of ten in this example. Because your enemy class already has a health variable, or spawn variable set you can write it once and then set each enemy to be a part of the class. I’m not sure where we have lost each other here. The difference being classes are declarative while nodes and scenes are imperative. Declarative meaning it doesn’t need to define its control flow. Imperative meaning it’s described step by step in detail. Are scripts/scenes similar to classes, yes, but they are not the same. As dor the node with a script attached you’ve created an imperative code. Rather than being declarative as in classes. There is extensive documentation on the godot site about classes and how they function if you have further confusion.
@harmoen
@harmoen Ай бұрын
​@@H3_remixI think what he's asking is why would you use classes instead of just instancing the scene/code you've already written.
@MartynaPanasiuk
@MartynaPanasiuk Ай бұрын
@@H3_remix Multiple instances of the enemy.tscn scene will share the same code file. Then if we export the health variable it can be made unique for each enemy directly in the editor. No need for classes or additional lines of code. @Queble this is a great tutorial, but I personally would really enjoy some more real-world examples of how classes are better than just instancing scenes!
Godot 4.3's Parallax Changes!
11:25
Queble
Рет қаралды 4,6 М.
How to Use CLASSES in Godot 4 (everything to know)
12:51
DevWorm
Рет қаралды 21 М.
🩷🩵VS👿
00:38
ISSEI / いっせい
Рет қаралды 27 МЛН
Ik Heb Aardbeien Gemaakt Van Kip🍓🐔😋
00:41
Cool Tool SHORTS Netherlands
Рет қаралды 9 МЛН
Мы сделали гигантские сухарики!  #большаяеда
00:44
10+1 INCREDIBLE addons for Godot 4
8:28
MrElipteach
Рет қаралды 31 М.
Best FREE Software for Game Development in (2024)
8:01
anyDev
Рет қаралды 38 М.
Master Tilemap PATHFINDING & Obstacle Avoidance in Godot 4.2
25:10
Cashew OldDew
Рет қаралды 14 М.
How to Use SIGNALS Correctly in Godot 4 (everything to know)
24:06
Smooth Up & Down Stair Handling | Godot 4 FPS Controller Tutorial
30:38
Classes In Godot Are Amazing!
19:22
Chaff Games
Рет қаралды 24 М.
How Games Make VFX (Demonstrated in Godot 4)
5:46
PlayWithFurcifer
Рет қаралды 338 М.
Godot 4.3 is Here!
19:20
Gamefromscratch
Рет қаралды 88 М.
🩷🩵VS👿
00:38
ISSEI / いっせい
Рет қаралды 27 МЛН