Advance your Code in Godot : Apply 3 Principles for any Project - Gdscript Tutorial

preview_player
Показать описание
Through the development of my RTS project I have come around some structural issues that were quite hard to figure out as I couldn't brainstorm solutions working with Godot,

So on this video I am going to share how I applied 3 important principles that allowed my project to be built as I wanted. This is some groundwork to implement the AI in my project as I want AI behaviors to be controlled through attributes.

Github Page Link for Traits System: (Godot-Proposals nº6416)

This video would have helped me a lot when I first started to brainstorm solutions for my project, so if you are building a RTS or a game with unique objects like an RPG, and you are thinking how to have a system that allows to design units easily just by changing some options, I am going to show you how I did it for my RTS project,

What I am going to present here took quite a while to figure out and stablish having started from scratch, hopefully you won't have the same issues as I had,

The first principle is what I have talked a lot in other videos, modular scripts, because at the moment Godot doesn't allow multiple inheritance in gdscript with it's classes, and the project I am building needs a lot of specialized isolated code, it's a perfect candidate to creating re-usable modular script pieces, so I have developed a system using static scripts in order to work around that problem,

The second one is about creating attributes for objects, the need for attributes was evident as RTS have many different objects that share the same structure but are completely different, making it quite a challenge to structure in code, however, having considered them as attributes I could create a solution that allows me to combine or separate as many attributes as I want, in order to build objects with a combination of different behaviors, using attributes is the way to go about that.

The third one is how the those two first ones allows you to build the complex objects we need, with modular code the behaviors we want can be isolated functions stored and ready to be used at anytime anywhere in another script, through attributes we can select and combine the behaviors we want, which in turn will allow us to make the complex objects we want.

This isn't a beginner tutorial, so if you don't completely understand, don't be discouraged, this is something that took quite some time to figure out, but I believe that it will be very useful if you want to build real complex games with Godot,
Рекомендации по теме
Комментарии
Автор

I feel like you could've used a bit flag field. export_flags var attributes ("ATTACKER", "HEALER"), etc.. For checking certain conditions you could've used a bitmask, simple bitwise comparison are extremely fast, and the storage is just a byte. You get the addeed benefits of being able to see what each bit is through the editor.

batomow
Автор

Thank you so much for the break down, really appreciate these types of videos.

lauraa
Автор

Acho que vou ter que assistir esse vídeo mais de uma vez pra entender como tudo se encaixa

AvocadoInvocado
Автор

COde Modularity....yeah, after I made godot do a thing and I realized I was making basically another copy of the same function, I abstracted that out into it's own class. This not only made the code reusable, but it also helped enforce reorganizing the code that used this class a little better.

scotmcpherson
Автор

Great lecture! I'm still a beginner, but I'll keep these concepts in mind while I'm learning! I'll have to come back to this again in a few months.

CassyCodes
Автор

Hi everyone. Have you thought of implementing modularity on lists, instead of using "if"s? Different lists for different tasks. Lists of node (references they are of course) for every task.

fnadal
Автор

Excellent info. To catch any issues with missing variables/attributes, maybe add some kind of automated check when the game starts up in combination with base classes that don't do anything and don't have dependenices? Instantiate one of each base class behind the scenes, so to say, and run the checks, then show an in-game warning in the main menu if something is missing. The other option could be a custom editor utility that scans certain scripts on demand, to determine if anything is missing.

Cymbalis
Автор

Cool video, thanks a bunch. I am prototyping a final fantasy tactics style game, and i will see if i can apply some of your optimizations. I never thought about how strings would slow the engine down compared to an array of bools, although I'm not sure it matters at my current scale 😂

DanielAttaway
Автор

Wow man this is amazing. Sometimes i find it hard to believe that free shit can be sk good

panwladca
Автор

🥇🥇🥇 is your game out yet or any of them? I'd love to check em out

panwladca
Автор

For a 2D RTS with many hundreds of units on the screen at once, what do you think about the cost of AnimationPlayer VS AnimatedSprite2D ? I know it's not quite your area but any insight would be so valuable to me

tavernking
Автор

Sounds like truncated self-made version of ECS. How making static functions executable over any object means modularity? How would you combine HEALER with WORKER and still have correct meaningful behavior? What will happen when AIR attribute appears? How 'move' function will work without knowing about other attributes? Sounds more like personal collection of workarounds and arguably bad practices. Maybe you shouldn't call this video not a guide nor a tutorial, maybe only a self experience.

wooodser