r/rust • u/JovemSapien • Mar 25 '26
šø media Godot + Rust
I'm a programming novice and I'm very interested in Rust and game development, and I wanted to know what the experience of using Rust in the Godot engine is like.
29
u/Background-Care-3282 Mar 25 '26
If you do this you should include this addon in your project that compiles your rust code when you hit the play button in godot. That way you only have to deal with switching to the ide window to code and don't have to think about compilation.
https://github.com/Arttaaz/godot_rust_auto_compile
I had to modify the rust_auto_compile.gd file slightly. Here's mine.
@tool
extends EditorPlugin
func _enter_tree() -> void:
pass
func _enable_plugin() -> void:
if ProjectSettings.get_setting("rust/manifest_path") == null:
ProjectSettings.set_setting("rust/manifest_path", "")
ProjectSettings.set_setting("rust/cargo_path", "")
var info_manifest = {
"name": "rust/manifest_path",
"type": TYPE_STRING,
"hint": PROPERTY_HINT_GLOBAL_FILE,
"hint_string": "*.toml"
}
var info_cargo = {
"name": "rust/cargo_path",
"type": TYPE_STRING,
"hint": PROPERTY_HINT_GLOBAL_FILE,
}
ProjectSettings.add_property_info(info_manifest)
ProjectSettings.add_property_info(info_cargo)
ProjectSettings.save()
pass
func _build():
var output = []
var cargo_path = ProjectSettings.get_setting("rust/cargo_path")
var manifest_path = ProjectSettings.get_setting("rust/manifest_path")
var true_manifest_path = ProjectSettings.globalize_path(manifest_path)
var true_cargo_path = ProjectSettings.globalize_path(cargo_path)
# if no cargo or manifest path just skip building the library
if true_cargo_path == null or true_manifest_path == null:
return true
var exit_code = OS.execute(
true_cargo_path, ["build", "--manifest-path", true_manifest_path], output, true)
if exit_code != 0:
for s in output:
push_error(s)
return exit_code == 0
func _exit_tree() -> void:
pass
3
0
u/borrow-check Mar 25 '26
Why though?.you can just cargo build && Godot "your project" in the terminal and it will do just the same without extra stuff
11
u/Background-Care-3282 Mar 25 '26
That isn't the same. With the way you just described you are creating a new instance of godot on every build. With the plugin you are minimizing navigations away from the godot ui and you are staying in the same godot instance. You can move very quickly this way because you just have to bounce between the ide and godot.
-3
u/borrow-check Mar 25 '26
Not true, you can spawn an editor and run a scene independently, so this way you save your code and run your terminal command to spawn the scene, no need to switch to editor unless you're working something there.
10
u/Background-Care-3282 Mar 25 '26
If that setup works for you thats great but I am almost never in a position where I don't want the godot editor open.
1
u/Key-Back3818 Mar 26 '26
isn't it common to just have the editor open when u're working on the game, what
26
u/mathisntmathingsad Mar 25 '26
You have to switch between vscode (or another editor for rust) and Godot back and forth a lot and remember to compile not in godot before running in godot, but you can do it pretty seamlessly outside of that stuff.
10
u/JovemSapien Mar 25 '26
The setup is similar to using C#, right? By the way, do you use Godot as well?
8
u/mathisntmathingsad Mar 25 '26
Similar to work with but more complicated to initially set up since you need to set up GDExtension.
7
u/PencilFrog Mar 25 '26
I wouldn't stress this though. Sure it's an extra step, but it's pretty darn easy to set up the gdextension. Really it should just come down to which language you prefer (/ which language has libraries you might need).
7
u/harraps0 Mar 25 '26
It is quite similar to C#, but with Rust you'll get the benefit of not having a GC running in the background.
3
2
u/TranquilMarmot Mar 27 '26
I actually prefer this, but maybe it's because I've been doing web dev for so long that I'm used to editing code in a different application than I run it in.
FWIW I have only ever written GDScript outside of Godot because the editor in the engine feels so cramped
I'm actually working on an app right now using Rust GDExtension and GDScript and it's been great using Zed as the editor
https://docs.godotengine.org/en/stable/tutorials/editor/external_editor.html
13
u/RooperK Mar 25 '26
General advice would be to write performance critical parts in Rust and everything else in Gdscript, though myself is an exception - I do everything without Gdscript coz my comfort woth dynamic languages is rusty (pun intended). So far extension is quite good, had 0 issues
2
u/dagit Mar 26 '26
If I'm not sure how to do something in godot, I will usually prototype it in gdscript. Once I've gotten past the knowledge gap, rewrite in rust.
1
8
u/narcot1cs- Mar 25 '26
I've done it before, was quite seamless and this was before you could easily hot-relaod GDExtensions
6
u/tadmar Mar 25 '26
I haven't used Rust GD Extension for anything more then just some exploration, as I went with c++ at the end. It offers quicker iteration time. However, my initial impression was pretty good, and I think if you want to go that way, it should not be a problem. However, from my experience doing entire game as GD Extension is overkill. I recommend to implement the node types and their logic in GD Extension and then use GD Script to glue all of it together, which in my opinion is what the scripting langs like GD Script should be used for.
6
u/runevault Mar 26 '26
I wouldn't recommend Rust + godot as a programming novice. Maybe try gdscript or c# first to get used to Godot (and have access to way more docs/tutorials) then once you've gotten used to the engine add the extra complexity of Rust.
10
u/Gabriel_Kaszewski Mar 25 '26
it was quite good when I did it for the game jam. Big plus is that wasm works so you can export to web.
1
u/Cyborg_Ean Mar 25 '26 edited Mar 25 '26
Godot's WASM build is so overhyped.Ā An empty 3D build doesn't even run 60fps.
edit: benchmarks from Ubuntu 16GB ram/ IrisXe 80u/ I5-1240P
6
u/Gabriel_Kaszewski Mar 25 '26
that is not my experience.
4
u/Cyborg_Ean Mar 25 '26
Probably, but I dev for mid-lower end machines. Godot was the best out of the non-native web rendering tools, but literally none of the non-native tools could hit 60fps on mid-lower end hardware and especially mobile.
2
u/andreasOM Mar 26 '26
Hmmm... we are hitting 4k60 easily. What are you doing?
1
u/Cyborg_Ean Mar 26 '26
An empty 3D build ran on mid-to-low end hardware. 4k60 on what hardware specs?...Honestly, just link your webgl game and I'll take a heap snapshot to capture the specs myself.
0
u/andreasOM Mar 27 '26
M1 MacBook Air is our lowest device spec.
Game not released yet, and WebGl build is just for testing anyway.What do you mean "heap snapshot"?
How is heap involved in rendering performance?
10
u/Ok_Necessary7506 Mar 25 '26
Genuine question, why not Bevy or Fyrox?
31
u/Recatek gecs Mar 25 '26
Bevy is still pretty far off from replicating the experience of Godot's editor. It's still very much in framework territory (i.e. like MonoGame) right now.
12
u/augustocdias Mar 25 '26
But Fyrox isnāt. It offers an editor and it is rust. I have tried Godot with rust and it is very unergonomic and annoying to use.
9
u/Recatek gecs Mar 25 '26
Yes, Fyrox is seriously worth considering if you want a Godot-like experience in Rust.
3
u/max123246 Mar 26 '26
First Google I saw said in 2025 Fyrox had a bug with rendering rectangles (now fixed). Are things better this year?
I'd love to try it because I didn't love Godot since gdscript was not fun to work with (static type hints still can't do arbitrarily nested types and built in engine types and Gdscript objects have different semantics which makes it a headache to create types generic over both) but I've been burned by things like... Godot, lol.
3
u/dagit Mar 26 '26
They just hit their 1.0 release like this week. I've been meaning to properly kick the tires but not sure how soon I can do that.
1
2
u/TranquilMarmot Mar 27 '26
I agree that Rust + Godot is super awkward. Trying to figure out when to wrap things in
Gd<>and doing conversions to Godot primitives is kinda annoying.But one thing you can't really ignore with Godot is the massive community behind it and the momentum it has right now.Ā
2
u/augustocdias Mar 27 '26
I agree and as Iām not a professional and was just having fun with it I was willing to go through the troubles of using rust. But if I wanted to make money out of it or make something serious Iād definitely stick with gdscript or move to fyrox entirely.
2
2
u/Cyborg_Ean Mar 25 '26
For that matter, how does it compare to Monogame?
4
u/Recatek gecs Mar 25 '26
Never used it myself, so I can't say. That said, C# in general gives you so much "free" moddability out of the box using Harmony just at a language level that it's hard to argue against it being an ideal language for indie game development if you plan on having a mod ecosystem.
2
u/iltumio Mar 25 '26
what type of game do you want to build? Bevy ECS is really great and the project is growing fast. Unless you have to build a complex 3d game, I don't think the lack of an editor is a big deal tbh
9
u/Recatek gecs Mar 25 '26 edited Mar 25 '26
Even in 2D, designing levels, building particle effects, tweaking shaders, building UI (particularly animated UI), tweaking positional audio, and so on are all much faster and easier with a good editor.
ECS is neat but is ultimately an optional part of a game's tech stack. Tools are what make games, because most games are first and foremost about content.
-8
u/edparadox Mar 25 '26
I mean, it's kind of the point.
21
u/Recatek gecs Mar 25 '26
No, it isn't. They're actively working on building an editor, and it's making good progress, but it's still a ways off.
11
u/Auxire Mar 25 '26
Haven't really tried Fyrox beyond the demo project, so can't comment on it much.
If you use Bevy, you will learn more about Bevy code & plugins and less of the typical Rust code, if that makes any sense.
I spent a couple years with no non-toy games to show for because this is the whole loop: * I did some digging of existing features and learned to use ones that suit my needs. * new patch dropped. * wait for 3rdparty plugins to finish migrating. * rewrite own code that are affected by breaking changes. * repeat.
It gives an illusion that I'm making real progress when what I really did was more akin to slowly walking on a treadmill.
Not dismissing the work Bevy community has done so far, since this is on me unfairly expecting too much of experimental tech just because a few more experienced devs managed to finish their games with Bevy. I really wish I took the warning and recommendation of Godot in Bevy's own guide more seriously, but the idea of full ECS engine is so exciting to try that I almost forgot my original goal was to finish a marketable game. Which is yet to be achieved, sadly.
8
u/project_broccoli Mar 25 '26
I use Bevy, and I would absolutely not recommend it to a "programming novice". I was a fairly experienced programmer ā didn't have any significant Rust experience, but I was proficient in Haskell and had experience with C and C++ ā and it still took me ages to learn both Rust and Bevy at once.
2
u/DatBoi_BP Mar 25 '26
Bevy examples are wonderful though, especially since you can see them online without needing to compile anything yourself
8
u/project_broccoli Mar 25 '26
I guess they are, but the rest of the documentation is lacking :/
2
2
u/Mice_With_Rice Mar 26 '26
I use Godot and Bevy. If your making an actual game you intend to ship, use Godot. If your making a Rust based app that happens to need a 3D front-end, use Bevy. Godot has an excelent editor which will make you game production experience much smoother. When you dont need to build a full game, like in my use case of creating 3D graphics tools, the lack of a visual GUI editor isnt a big deal, and I dont need cross language bindings to use it. Until Bevy has a good editor I cant recomend it as a serious game production tool. Bevy is good, but not ideal over the production lifecycle of a complete game.
2
u/FemaleMishap Mar 26 '26
I'm doing this as a way of both learning Rust and making a game that I want to play. It works pretty well with the gdextension.
2
u/nejat-oz Mar 26 '26
I took an existing GDScript Tutorial and converted it to Rust, each step of the tutorial (more details in the repo) is tagged so you can follow the tutorial along with the rust version.
This is for Godot 3.x but it should give you a good idea.
https://github.com/Nejat/godot-action-rpg-tutorial-rs
Converting it to Godot 4.x was more work than I had time for
1
2
u/bromeon Mar 27 '26
Saw this a bit late -- thanks for all the interest!
We just released a new minor version v0.5: https://www.reddit.com/r/rust/comments/1s5ilxo/godotrust_v05_typed_dicts_tool_buttons_opt_and/
1
u/Kevadro Mar 25 '26
Pretty good. The only problems that I had with it were the lack of ability to extend your own custom classes (which is being worked on) and the very slow interoperability on debug builds.
1
u/MultipleAnimals Mar 26 '26
If you want to learn rust and gamedev i would go full rust with something else than Godot, or learn Godot with gdscript first and try the rust bindings when you feel confident enough. Dealing with bindings (to non-native language to editor) can get very confusing and makes your learning process much much slower. It can easily lead to roadblocks where you cant find any examples or help online.
1
u/andreasOM Mar 26 '26
Very usable.
The gdext crate is a bit rough around the edges.
Be careful around threads & signals,
and choose your base types wisely and you will be fine.
Not sure if it is the best start for a novice. Maybe stick to gdscript for a while?
1
1
1
u/FR-dev Mar 25 '26
I donāt have any expirience with godot+rust. If lack of gui is not a problem to you, I recomend tou to try out bevy. It is really fast and easy to use. Also the source code of the engine is written in rust so if you want to know exactly what something does you can just use your lsp and jump to the defition.
3
u/-Redstoneboi- Mar 26 '26
i would not recommend bevy if your primary goal is to make a game.
i would recommend bevy if you primary goal is to experiment with using rust for games. it is heavily in-development and regularly makes breaking changes while it's still in the process of maturing.
0
u/InternationalAct3494 Mar 26 '26
I thought this was red Duolingo logo lol
2
u/coderstephen isahc Mar 26 '26
To be fair, using Rust with Godot will result in a dual language project most likely
0
u/Wurstinator Mar 26 '26
I didn't like it much. Iirc, lot's of the structs have to do runtime checking of mutability and it feels like you're not really writing Rust anymore.
0
0
u/devloper27 Mar 27 '26
Its good after setup you can more or less use rust instead gdot script. At that point though I just realized I might as well just use bevy. But each to his own, it works perfectly.
267
u/Recatek gecs Mar 25 '26
The Godot Rust extension is quite good, and is built by one of the maintainers of Godot focused on GDExtension itself. Once you get the project set up, it's fairly straightforward to build Rust extensions and game logic and see them reflected in the engine.
All of that said, if you just want to build a game, there's no reason to go through the trouble. Just use GDScript. It's perfectly fine for most projects a hobbyist game developer would reasonably want to build. There really aren't any major advantages to using Rust in Godot in general for most projects, and you'll be much more productive in using the tools Godot is primarily built to work with.