godot-rust

61 readers
1 users here now

Community to share news about the godot-rust project and to help each other! Both for GDNative (Godot 3 and under) and the (experimental) gdext for Godot 4!

Also feel free to share your tutorials or own projects using the Rust bindings for Godot!

Official links:

founded 1 year ago
MODERATORS
1
8
Godot-rust now on crates.io (godot-rust.github.io)
submitted 5 months ago by hiddenSin to c/godot_rust
2
6
submitted 9 months ago by tuto193 to c/godot_rust
3
5
Godot-rust now has a devlog! (godot-rust.github.io)
submitted 1 year ago by tuto193 to c/godot_rust
4
 
 

From Bromeon:

"Small API change with https://github.com/godot-rust/gdext/pull/370.

There is no more implicit base in user methods, to make a clearer separation between the Rust object (self) and the Godot one (self.base).

fn method(&self) {
    // instead of:
    let pos = self.get_position();
    // now:
    let pos = self.base.get_position();
}

On the other hand, Gd now always has Deref and DerefMut, not only for Godot objects.

fn free_function() {
    let obj: Gd = ...;

    // instead of:
    let pos = obj.bind().get_position(); // or
    let pos = obj.upcast::().get_position();
    // now:
    let pos = obj.get_position();
}

I also improved some safety around the internal instance storage in the process.

In the near future, we need to observe whether the slightly more verbose self.base instead of self is a real issue in practice. However, it comes with quite a few advantages:

  • It's easier to keep the user object self and the Godot object self.base apart, when not all symbols are in one namespace.
  • It's less tempting to do gd.bind_mut().get_position().
    • Now it would be gd.bind_mut().base.get_position() -- however one can as well do gd.get_position() directly. The user is encouraged in the right direction.
  • Users can implement their own custom Deref/DerefMut on T, we don't impose an implementation.
  • We don't cause compilation errors due to orphan rule, if T lives in another crate.

So if you want to update, keep in mind that this has not yet fully settled and may see some changes again ๐Ÿ˜‰"

5
 
 

A world-bending platformer uses godot-rust's GDNative bindings (made in Godot 3.3.3)