Getting Started with Godot-Rust



Original website: https://godot-rust.github.io/book/

1. Download Godot Engine

Download and install Godot Engine from the official website.


2. Install Rust

Use the following commands in your terminal:

# Linux (distro-independent)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Windows
winget install -e --id Rustlang.Rustup

# macOS
brew install rustup

Once installation is complete, continue to the next step.


3. Create the Project Structure

Set up your folders like this:

project_root/
├── rust/
└── godot/

4. Create the Rust Project

Inside the rust folder, run:

cargo new project_name --lib

This will generate a Cargo.toml file like this:

[package]
name = "rust_project"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

Add the dependency:

[dependencies]
godot = "0.5.1"

Or use the latest version from GitHub:

godot = { git = "https://github.com/godot-rust/gdext", branch = "master" }



Important note (Linux):
When creating the project, Cargo may generate an extra nested folder.
Move the inner project files directly into the rust folder.

If you don’t do this, cargo build may fail because:

  • Cargo.toml will be in the wrong place
  • The .gdextension file path will not match

5. Create the Godot Project

Create your Godot Engine project inside the root folder (project_root/godot).

You don’t need to move anything here because:

  • The .gdextension file will reference this location correctly

If you want to export your game (e.g., for Linux), you can check demo projects here


6. Create the .gdextension File

Inside the godot folder, create a file named:

project_name.gdextension

Define the export paths inside this file.

You can create it using:

  • VS Code
  • Or your system file explorer

7. Try a Demo or Build Your Own

You can:

No comments:

Post a Comment