Тёмный

How to use Classes in Godot! - Intermediate Tutorial 

Queble
Подписаться 7 тыс.
Просмотров 11 тыс.
50% 1

Хобби

Опубликовано:

 

4 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 47   
@ched4516
@ched4516 3 месяца назад
This tutorial was much easier to understand on the specifics without going too far off subject. Keep up the good work.
@almostleonan938
@almostleonan938 Месяц назад
For me as a beginner, that was the best explanation for class I watched. Nice job!
@sebashtioon_
@sebashtioon_ 3 месяца назад
Thank you! Very confused about classes before this but now I understand them. ❤
@queblegamedevelopment4143
@queblegamedevelopment4143 3 месяца назад
Awesome, glad I could help!
@konvay_vardogr
@konvay_vardogr 24 дня назад
Super easy to understand Class tutorial. Godot is really showing itself to be a very powerful engine, being able to create your own Nodes with one line is a powerful tool for developers to pull into any project and reuse their code.
@MathieuHaas68
@MathieuHaas68 11 дней назад
Awesome job truly! This makes it clear for almost anyone!
@buzzbuzz20xx
@buzzbuzz20xx Месяц назад
This is just a simple and straightforward way of explaining classes and inheritance!
@kynda
@kynda 3 месяца назад
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.
@NathanielMerck-y7j
@NathanielMerck-y7j Месяц назад
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!
@GabeNarwhal
@GabeNarwhal 4 месяца назад
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!
@cbrauny8576
@cbrauny8576 29 дней назад
This tutorial was very helpful, thanks!
@xtoo550
@xtoo550 Месяц назад
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!
@何志颖
@何志颖 4 месяца назад
Good job,I want to see a video about how to do trade-off between inherit and composition in Godot.
@Danachew
@Danachew 4 месяца назад
A video on building different custom resources would be awesome!
@lout160
@lout160 4 месяца назад
I can confirm. This would be undoubtedly awesome. Very necessary.
@do_it_like_rei
@do_it_like_rei 4 месяца назад
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 :)
@legarscringe2853
@legarscringe2853 10 дней назад
Thank you soo much buddy this video was very good
@SoyIbrag
@SoyIbrag Месяц назад
TYSM! Keep up the good work!
@fvhaudsilhvdfs
@fvhaudsilhvdfs 4 месяца назад
we crave another custom resources video :)
@lout160
@lout160 4 месяца назад
We do. We crave it!
@Nishisaki405
@Nishisaki405 2 месяца назад
This was amazing. Thanks a lot
@LouisDoesGames
@LouisDoesGames Месяц назад
nice video thanks a lot!!
@aahh437
@aahh437 4 месяца назад
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 4 месяца назад
I'll add that idea to the list! :)
@thegameissimple
@thegameissimple 4 месяца назад
Use inheritance only when composition is logically impossible. In all other cases prefer composition. And don't inherit deeper than two levels.
@AtelicDev
@AtelicDev 3 месяца назад
Awesome tutorial!
@LouisDoesGames
@LouisDoesGames Месяц назад
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?
@blazenetic
@blazenetic 4 месяца назад
Very well done 👍
@ukrsolid
@ukrsolid 24 дня назад
resources tutorial please, thanks for this Tutorial
@lml55
@lml55 Месяц назад
please explain inner class omg bro no one on this platform is explaining this one concept
@DanielAraujo92
@DanielAraujo92 Месяц назад
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?
@lout160
@lout160 4 месяца назад
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 4 месяца назад
Planning on extending this video with a custom resource attack system:)
@PhilChilled
@PhilChilled 2 месяца назад
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 2 месяца назад
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!
@ThePlecoPal
@ThePlecoPal 16 дней назад
I figured out octrees before figuring out what a class meant☠️
@Sunflower-lk2xo
@Sunflower-lk2xo 3 месяца назад
How do you give an instance of a class its own unique variable?
@queblegamedevelopment4143
@queblegamedevelopment4143 3 месяца назад
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
@PandaManArchives
@PandaManArchives 17 дней назад
class vs inheritance? ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-rJaX19t67AA.html can I mix the 2?
@queblegamedevelopment4143
@queblegamedevelopment4143 17 дней назад
So classes and inheritance are essentially the same thing. Let's say you have a Entity class with and entity name, then 2 sub classes: Player and Enemy. These 2 subclasses also would have an entity name, so they would both inherit from the entity class. This is called inheritance, because we have two subclasses inheriting from the parent class AKA entity. What you might be talking about, and something I would suggest looking into, is using a component system rather than inheritance
@Ceisri
@Ceisri 3 месяца назад
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 3 месяца назад
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 3 месяца назад
@@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 3 месяца назад
@@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 2 месяца назад
​@@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 2 месяца назад
@@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
Просмотров 6 тыс.
Living life on the edge 😳 #wrc
00:17
Просмотров 7 млн
ВЫЖИЛ В ДРЕВНЕМ ЕГИПТЕ!
13:09
Просмотров 180 тыс.
Godot Scripts I add to Every Game
12:34
Просмотров 21 тыс.
How to Use CLASSES in Godot 4 (everything to know)
12:51
Start using Metadata in Godot!
7:18
Просмотров 10 тыс.
Immersive Sim in Godot 4: COGITO - Overview
8:22
Просмотров 42 тыс.
Classes In Godot Are Amazing!
19:22
Просмотров 25 тыс.
I Made Minecraft in Godot
28:36
Просмотров 56 тыс.
Learn Godot UI Control Nodes
24:22
Просмотров 20 тыс.
2 октября 2024 г.
0:14
Просмотров 774 тыс.