Skip to content

[WIP] Add Multiplayer Bomber Demo#21

Draft
ValorZard wants to merge 7 commits intogodot-rust:masterfrom
ValorZard:bomber
Draft

[WIP] Add Multiplayer Bomber Demo#21
ValorZard wants to merge 7 commits intogodot-rust:masterfrom
ValorZard:bomber

Conversation

@ValorZard
Copy link
Copy Markdown
Contributor

@ValorZard ValorZard commented Mar 19, 2026

Take 2!

currently in draft because im getting a weird error when I try to start the game

E 0:00:05:602   player.gd:71 @ set_player_name(): [panic C:\Users\sraya\.cargo\git\checkouts\gdext-067f4b88e7bd088f\2417d4a\godot-core\src\storage\mod.rs:26]
  Gd<T>::bind() failed, already bound; T = multiplayer_bomber::gamestate::GameState.
    Make sure to use `self.base_mut()` or `self.base()` instead of `self.to_gd()` when possible.
    Details: cannot borrow while accessible mutable borrow exists.
  in GameState::get_player_color()
  <C++ Source>  C:\Users\sraya\.cargo\git\checkouts\gdext-067f4b88e7bd088f\2417d4a\godot-core\src\private.rs:354 @ godot_core::private::set_gdext_hook::{{closure}}()
  <Stack Trace> player.gd:71 @ set_player_name()
                lobby.gd:90 @ _on_start_pressed()

To replicate bug, have two clients running in the Godot editor.
Like so:
image

image Then, on the host side, press start game and you'll get this error

@ValorZard
Copy link
Copy Markdown
Contributor Author

I don't really understand why, but switching out

#[func]
    fn get_player_color(&mut self, p_name: GString) -> Color {
        Color::from_hsv(godot::global::wrapf(p_name.hash_u32() as f64 * 0.001, 0.0, 1.0), 0.6, 1.0)
    }

to this

#[func]
    fn get_player_color(p_name: GString) -> Color {
        Color::from_hsv(godot::global::wrapf(p_name.hash_u32() as f64 * 0.001, 0.0, 1.0), 0.6, 1.0)
    }

seemed to fix it

@TitanNano
Copy link
Copy Markdown

@ValorZard you call rpc("set_player_name") from Gamestate::begin_game, this causes a re-entrant call.

GameState::begin_game (Rust) -> Node::rpc (Engine) -> player.gd::set_player_name (Engine) -> GameState::get_player_color (Rust)

@Bromeon
Copy link
Copy Markdown
Member

Bromeon commented Mar 19, 2026

We originally closed #1 in favor of a simpler net pong example, see #10 (comment). There were concerns about maintenance1, and whether this example would actually showcase more godot-rust features than net-pong.

Has this situation changed?

Footnotes

  1. not just API changes, but hunting down bugs related to networking or other platform-specific parts.

@ValorZard
Copy link
Copy Markdown
Contributor Author

We originally closed #1 in favor of a simpler net pong example, see #10 (comment). There were concerns about maintenance1, and whether this example would actually showcase more godot-rust features than net-pong.

Has this situation changed?

Footnotes

  1. not just API changes, but hunting down bugs related to networking or other platform-specific parts.

This is mostly an experiment on my part to see how it would feel to do this project with all the new API updates.

I was hoping that if we got the new typed RPC stuff it would make this type of thing a lot easier

I do think that there are some Godot rust features that this project showcase- namely custom variants and singleton/ auto loads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants