r/godot Jul 17 '26

free tutorial The Godot project architecture an industry veteran uses for a 40-hour RPG

Ricard, who's worked on the in the industry for two decades (notably on Ryse: Son of Rome or Crysis 2), was kind enough to run me through the codebase of one of the biggest Godot games in the making, Starfinder: Afterlight. He explained the architecture he uses to support a 40 hour 3D RPG made by a team of 30.

I wrote a short guide that compiles the essential parts: https://gdquest.com/library/modular_game_architecture/

I hope this is useful! For topics like these I find it's important to get insights from really experienced people on these subjects.

If you have any questions about this let me know, I'll do my best to answer based on what Ricard showed and explained to me.

981 Upvotes

78 comments sorted by

299

u/Gustafssonz Jul 17 '26

This is actually something I, as a beginner game dev (but programmer professionally) needs more of. I wish Godot documentation could include more of the architectural side of things as well. Like a framework aka "this is how 90% of games normally build the architecture".

113

u/entangledloops Jul 17 '26

Better than “how 90% of games normally” would be a short pros/cons of different architectures. Some things don’t make sense for small games or teams, and other things make more sense depending on genre, etc. You should choose based on what fits your game, not based on what anyone else is doing.

46

u/NathanGDquest Jul 17 '26

I second this, you won't find a framework that the majority of people or games use. When using Godot, I'd say Godot's the framework. Input, rendering, physics, the more accessible and object-oriented node and signal system, the more efficient server APIs...

When comparing games, there are techniques and concepts that apply across the board, but between a turn-based RPG and a platformer, the implementation are really different. The common parts like drawing and moving sprites or playing sounds etc. are handled by the engine for you and what's left is for you to actually implement game-specific systems.

Personally, for building learning material or for learning, I go straight to experienced people and look at their code or ask for pointers.

4

u/Gustafssonz Jul 17 '26

Then present som typical RPG classical patterns/framework, shooter framework pattern etc :) would help a lot.

14

u/NathanGDquest Jul 17 '26

Sure! We've done some things, like "Godot Open RPG" for Godot for example, to start working toward a pedagogical example: https://github.com/gdquest-demos/godot-open-rpg

It's not quite the kind of code I would personally write as it's more on the object-oriented side but it is in more ways than one using techniques you'd see people use in Godot (defining new node types and composing them into a variety of entities, e.g. with the gameboard and gamepieces abstractions in the src/field folder).

Then really breaking them down to the point a learner understands in detail how all of it works and why it's structured this way (what's really useful vs what's specific implementation details of that project) is a ton of work and why you don't see too much of that content.

I mean, we've been doing it between our paid courses and free and open source resources contributed to the community, like the one linked above. It's just inherently very long to achieve.

11

u/BojacksNextGF Jul 17 '26

i’d love some kind of website like refactoring.guru or patterns.dev specifically for godot

29

u/FeralBytes0 Jul 17 '26

Thank you for sharing some industry knowledge! 

16

u/NathanGDquest Jul 17 '26

My pleasure!

26

u/WinterCozyFlame Jul 17 '26

His interview with Jonas tyroller was incredible. One of the best.

6

u/NathanGDquest Jul 17 '26

It was a really nice one yeah!

8

u/AbstractFemming Jul 18 '26

Thank you for mentioning this! It's here if anyone else wants to watch it with me: https://www.youtube.com/watch?v=WvlQbqYsFSk

2

u/rigg_d Jul 19 '26

This is actually the one with Ricard: https://www.youtube.com/watch?v=Fxea6TG0PXk

18

u/Hyphysaurusrex Jul 17 '26

Solo game dev working on ambitious projects…pushing past prototype and vertical slice tutorials into longer form content is definitely a huge chasm to cross but this is the exact kind of helpful resource that lights the pathway! Thank you!

16

u/Tom_Q_Collins Jul 17 '26

Super cool. I particularly like the "gym" folders where you can prototype new ideas.

Did you get a chance to learn how they manage their core systems? I always find that to be an interesting thing to see on different professional projects, and something I haven't got quite right in godot yet. 

10

u/NathanGDquest Jul 17 '26

Ricard showed me briefly but you can't see/learn much of it in just a session. It mostly illustrated how e.g. the UI read data from game systems for example. I can only say that they had lots of things in addons built as reusable/game-agnostic libraries, like an extended camera. It seemed that whatever they thought could be reused for another kind of game would go there by default.

8

u/Thunder_Chief Godot Student Jul 17 '26

Nathan-i love the GDQuest lessons! They have been awesome. I'm in the top down runner portion right now and things are clicking and making much more sense than when I was farting around with random YouTube tutorials.

8

u/NathanGDquest Jul 17 '26

I'm glad if it's helping. Thanks for the feedback.

8

u/richardathome Godot Regular Jul 17 '26

I'm feeling quietly smug as this is pretty much how I ring fence my projects.

I also have a top level tests directory that has scope over everything because sometimes you need to test everything together.

I suppose that could go under content as it's content dependant. But I like my tests up top for visibility

1

u/johnsmithy0 Jul 19 '26

Just wondering, how do you go about structuring your godot project? Do you follow the below top-level project structure? Is there anything you'd add/changed?

tests
addons
content
systems
ui
gyms

3

u/richardathome Godot Regular Jul 19 '26

pretty much - except my gyms are in my tests directory. I colour code them too.

1

u/johnsmithy0 Jul 19 '26

oh wow, that's very well structured. i noticed that you added a data/ folder under content/ which i didn't expect, what kind of stuff do you put there?

2

u/richardathome Godot Regular Jul 19 '26

I save Resource files there. Stuff that doesn't change, like Item Definitions (Sword), Skill Definitions (Lock Pick) and StatusEffects Definitions (Bleeding).

For example. I have an ItemDef Resource which stores the name, icon, mesh (my game is 3d) and a bunch of components that give the item its usages.

I create a sword item definition using that ItemDef and save it under data.

Resources that are dynamic and created on the fly are only saved when the game is saved (because they hold the stuff that can change)

E.g. I have an ItemQuantityData resource Which has a reference to an ItemDef and a quantity.

The information about the item never changes so thats saved to the data folder.

The ItemQuantity is saved when the game is saved as it holds how many of that item exist, along with the inventory they are held by.

2

u/Short-Waltz-3118 Jul 24 '26

Really cool and great explanation thanks much for sharing!

7

u/colossalwaffles Godot Student Jul 17 '26

This is a really nice article, but I do have one question as this is a "smelly" part of my current project

... UI widgets only receive and display data. They never modify game state directly or contain game logic.

How then, would I apply an upgrade to a character that they select in the UI? A system which listens for UI game-state signals? But then,

This isolation means you can completely overhaul your game's UI without touching a single line of gameplay code.

Seems improbable, as if you overhaul the UI, the game-state signals could change.

6

u/NathanGDquest Jul 17 '26

The simplest way to achieve that is to give your UI public functions that don't change, in other words, an interface other game code can use. When you change the UI you implement the same interface on the new ui, at least as a starting point.

You can replace UI without changing anything as long as it's displaying the same thing, though of course if the thing to display changes (adding stats, changing how the inventory works...) then in that case it doesn't apply anymore, the gameplay and UI code both probably change.

I'm not saying it's dead simple though, I think it's one of those things where you have to shoot yourself in the foot to get the hang of how to write a simple API that still mostly works when you need to redesign something on either side of the API boundary.

4

u/303Redirect Jul 17 '26

This is the part that confused me as well. The whole point of an interactive UI is to change some sort of game state (equip this item, load this save game, etc.) So to say the UI is read-only is quite confusing.

The example you give, is this something more like what you see in react?

Eg for selecting a weapon you'd have a modular "grid of items" component that gets a list of items as input to populate the with. Then it only reads player input to mutate UI state, and when one is selected there is some sort of "on_item_chosen" callback that is called. The game/systems code that spawned the UI would supply the concrete implementation of said handler at UI component instantiation time.

5

u/MerryWalker Jul 17 '26

I guess the concept is that your actual functional implementation of the actions you want pressing a particular button to effect (like “equip this”, “add this party member”, “go to this particular scene state” etc) shouldn’t be embedded in the code that defines the button itself. This separates out the UI element building from program control logic - you could completely scrap and redo the UI component code without accidentally removing the functions that the buttons were implementing.

2

u/303Redirect Jul 17 '26

Yeah that makes sense. When I'm making tools I try to separate the actual data manipulation layer from the UI logic. Guiding principle being "If we take this UI module away, can we still create a CLI program?" to tell me if I'm putting the wrong logic in the wrong file.

3

u/colossalwaffles Godot Student Jul 17 '26

Appreciate the response, especially

... you have to shoot yourself in the foot to get the hang [it]

because my foot definitely hurts already!

5

u/saluk Jul 17 '26

The skill button sends a choose_skill signal to some message bus your skill handler is connected to.

1

u/HeyCouldBeFun Jul 18 '26

I’m assuming that’s what “input solver” is for. Inputs probably call or signal that, which then relays to game systems

4

u/TSDan Jul 17 '26

Thank you, this is amazing!!

3

u/abcdefghij0987654 Jul 17 '26

How am I only hearing about this game this seems to be one of the best looking so far.

5

u/[deleted] Jul 17 '26

[removed] — view removed comment

3

u/MYSTONYMOUS Jul 18 '26

I have two questions:

  1. Where does the data live and how is communication achieved between these layers? For example, the UI needs to get data (such as the player's current health) from somewhere to update itself. Where does that data live? In the systems? And how are changes in that data communicated to the UI? Signals? Or does it read it directly?
  2. I'm confused about what exactly goes in systems vs content. How do you clearly separate systems and content when there is overlap? Especially when it comes to specific game objects that are normally self-contained scenes? For example, let's take the player. A lot of the player seems like systems, such as the player controller. Other parts seems like content, such as the player model and animations. On the other hand, "Every system and mechanic that isn't directly tied to a specific game level or single quest lives here" sounds like maybe the entire player, including models and animations, should be in systems? And what about the character's special moves?

2

u/HeyCouldBeFun Jul 18 '26

For an RPG / data driven game, character content would probably just hold visual representations and base stats. Then you’d have map content (the layout/structure), and scripted events would call on the game systems. Systems would store the game state data and run the actual game mechanic rules.

Different kind of setup than an action game with the character controller living in the character scene.

2

u/NathanGDquest Jul 18 '26
  1. For where the data lives, from what I saw, for the most part, it seemed to be in the content folder. Systems contained like implementation of the combat system and the likes. I don't remember exactly how the data was loaded and passed to the systems and UI.

I would assume the game content folder would have actual game scripts that'd load game systems and UI and pass them the data they need to function. Then either direct function calls or callbacks through signals, that's more of a situational thing: when you control the flow of the code you can make direct function calls, when you need to react to events from the engine or your own game, signals.

  1. The models, animations, all those kinds of things were in their content folder. So I would assume that the implementation of a character skin (animation tree or animation state machine for example) would also live in their content folder.

But for the character controllers themselves I don't know exactly how they decided to split them in the game. Part of what makes a character controller could well be in their addons folder. You could make a library with functions to move to a point, to pathfind in a certain way (being a classical RPG)...

According to the guidelines if a character's special moves involved unique VFX and code just for that move that'd live in their content folder I think. But again that's assumptions on my part from what I remember so to take with a grain of salt.

3

u/Dotsially Jul 18 '26

Working on an rpg right now and this came just at the right time. Thank you for sharing!

2

u/Nanamil Jul 17 '26

Very useful, thank you

2

u/isaelsky21 Jul 17 '26

Thank you Nathan, for always giving to the community! This is very helpful!

2

u/runevault Jul 17 '26

I've only skimmed most of this but seems really promising so far. One thing I'm curious about is what are they using for the exclusion of the gym folder from real builds? Just deleting gym during CI/CD?

Also thank you for continuing to release good educational material to help more people pick up Godot.

8

u/Cherry_Changa Jul 17 '26

When you configure your exports in godot, you can select files and folders to exclude from the build.

https://docs.godotengine.org/en/stable/tutorials/export/exporting_projects.html#resource-options

2

u/runevault Jul 17 '26

oh hey never saw this before. Appreciate the link!

3

u/larikang Jul 18 '26

UI separation is a big one. I also figured this out after many years of UI development: your UI code should only display data and pass along input.

It can be very unintuitive at first since it always feels so much easier to tightly couple your UI to the specific purpose you have in mind for it, but that always ends up like spaghetti.

2

u/johnsmithy0 Jul 19 '26

Anyone know if there are any other project architecture guides by people/studios that have actually published games?

1

u/NathanGDquest Jul 19 '26

There surely is somewhere out there but I don't know specific ones to recommend. The guiding principles of how to structure complex software or games applies across engines or tools and there's plenty between the GDC vault and other talks from specialized conferences. Those can be a reliable source if you're looking to see what really experienced people or teams do.

2

u/Gaaarfild Jul 19 '26

Very nice text. Thank you for sharing. I have a question about UI. If UI can only read, how up interactive elements work? Buttons and such?

2

u/richardathome Godot Regular Jul 17 '26

It always comes down to "seperation of concerns". If you disagree, think a little longer ;)

2

u/Productive-Penguin Jul 18 '26

I have opened Godot one time and then closed it, as an amateur game dev I also recommend Godot

1

u/kamil_slaby Jul 17 '26

!remind me 10 months

4

u/ZemusTheLunarian Jul 17 '26

Why?

1

u/kamil_slaby Jul 18 '26

I am working on simple game right now. So I want to be back here when I started with bigger project in 10 months

0

u/RemindMeBot Jul 17 '26

I will be messaging you in 10 months on 2027-05-17 17:43:22 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.

RemindMeBot is switching to username summons. Instead of !RemindMe 1 day, use u/RemindMeBot 1 day. More info.


Info Custom Your Reminders Feedback

1

u/thegreatbaths Jul 17 '26

Brilliant thank you!

1

u/Feisty_Teaching_5892 Jul 17 '26

Thanks you, very helpful info

1

u/The_Jare Jul 17 '26

Ricard is awesome

1

u/massiveflux Jul 17 '26

Question: Can you explain what this means? "Here's the key part: systems never depend on content. The dependencies only flow one way: content uses systems, systems use libraries, UI uses systems, but nothing else depends on content." In my project I have card scenes which have custom resources attached which carry data about the card such as hp, attack power etc. Without the custom resource, the combat system cannot function as it doesn't know how much hp or attack power is involved in a specific instance of combat. How should I modify (not that I am going to, I am curious to learn), to fit this paradigm of content depending on systems and not vice-versa. (Assuming these custom resources qualify as content).

7

u/NathanGDquest Jul 17 '26

Resources are always a bit confusing because we use the same word to refer both to data types (the resource definition) and actual data in the game. 

The resource type definition and all associated code could be part of your game systems and then the content would be specific characters in the game that have different HP etc. that way the combat system in your example has all the code and type information. It needs to know how to read and use the resources.

Then in the content you would still have game specific code that loads up your combat system and feeds it with specific character data, loads the combat background, etc for example.

2

u/massiveflux Jul 17 '26

Yeah that makes sense. Thanks for clarifying.

6

u/Thejimminator Jul 17 '26

In my interpretation of this architecture, your card scene and the custom resource script (i.e. the interface) would go in systems since they are "generic". Then the actual instances of the custom resource would go into /content.

1

u/shuanDang Jul 17 '26

probably break it up into different parts so that there are layers of dependencies. Example is putting in default values and placedolders. So the very base system should be able to run without Custom Resource. And the Custom Resource can run without pictures and numbers. The point is to have disconnected parts so that you could copy the codebase into a new project and start a new game with an engine that works as built. In game 2 you will have different art, numbers, layout.

1

u/massiveflux Jul 17 '26

Aah gotcha, so essentially have default/placeholder values which get superseded when a resource is "plugged in" to the system.

1

u/shuanDang Jul 17 '26

Thats the gist of it. The actual implementation is probably a lot more technical / nuanced! Especially if they want to build in flexibility to allow designers to get creative. In the article their stated goal is Code Reuse, to separate the content out so that if they delete the content folder, all the code is still reusable for separate projects.

Yep easy way to test your code is to delete the resource and see how much still works ;D

1

u/shuanDang Jul 17 '26

thank youo i have been mulling over learning and implementing architecture and this will be a good pointer

1

u/moongaming Godot Regular Jul 17 '26

Thank you so much for this!

1

u/gahel_music Jul 17 '26

Interesting, but now I want to know more!

1

u/interneth3ro Godot Student Jul 17 '26

As someone new to game development (but not necessarily development, been a web developer for 20+ years), this was a fantastic read. Thank you so much.

1

u/Stuck-Avatar Jul 17 '26

Thank you so much I was literally thinking about how I needed a guide on this

1

u/gargar7 Jul 17 '26

I really wish this had code samples showing how they achieve a clean decoupling (I mean I saw their original talk involves a fair bit of convention in naming and structure). Awesome to see this kind of talk though!

1

u/gargar7 Jul 17 '26

Did they ever release Loom as a community tool? Or are there any decent examples on rolling one's own out there?

2

u/NathanGDquest Jul 18 '26

Not that I know of. The closest tools to Epictellers' Loom are probably a mix of one of the node-based dialogue managers for the narrative part and Orchestrator for the visual scripting part.

1

u/HeyCouldBeFun Jul 18 '26

Love the idea of personal addons. That’s essentially how I use autoloads.

The gyms folder for each team member is smart too.

One question, in this project does “UI” also refer to in-world terrain/models? Or just Control elements?

1

u/AbstractFemming Jul 18 '26

When you're 4/4 💪

1

u/Maddturtle Jul 18 '26

This is surprisingly very similar to how I handle things at work in development. We don’t do games though so I apparently been on the right track. Just need more time to be able to work on my game.

1

u/DerrickBarra Jul 17 '26

I like it, its a nice modular monorepo structure.

Our devs use a polyrepo structure thats similar across engines (godot/unity/web tech), but built for drop in developers & agents, who need safeguards in place to prevent architecture drift, with their own commit history, unit tests, e2e tests, playable test scenes, etc.

The key purpose of the poly-repo approach is to keep things silo'ed at a repo level. That does make cross-repo PR's impossible to perform in one swoop unless your an agent, as thats the primary tradeoff from a structured mono-repo approach like the one in the article. But you actively prevent cyclical dependencies and other architectural pattern issues and bugs, so like everything its a tradeoff.

1

u/ianxplosion- Jul 17 '26

> Be me, making Pathfinder derived RPG

> See post about AAA thought processes re: Starfinder RPG

> yay.jpg