Amethyst Site

Discourse Hub Dev

This is a experimental feature, ignore this.

Launch Hub

Pong tutorial panics when adding UiBundle

I’ve worked my way through most of the pong tutorial but I’ve run into an issue with part 5 of the pong tutorial trying to add the scorekeeping UI. Adding the .with_bundle(UiBundle::<stringBindings>::new())? method results in the following panic:

thread 'main' panicked at 'Tried to fetch resource of type `Hierarchy<Parent>`[^1] from the `World`, but the resource does not exist.

You may ensure the resource exists through one of the following methods:

* Inserting it when the world is created: `world.insert(..)`.
* If the resource implements `Default`, include it in a system's `SystemData`, and ensure the system is registered in the dispatcher.
* If the resource does not implement `Default`, insert it in the world during `System::setup`.

[^1]: Full type name: `specs_hierarchy::Hierarchy<amethyst_core::transform::components::parent::Parent>`', C:\Users\redne\.cargo\registry\src\\shred-0.10.2\src\world\
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\pong.exe` (exit code: 101)

I’ve shuffled the order of my .add_bundle()? methods around a bit in case they were dependent on the order they were run but with no effect. I’ve also had no luck comparing my code to the example on the GitHub since that uses a DispatcherBuilder instead of a GameDataBuilder and is different in a whole host of other ways from where my code stands.

Here’s the segment of code where I’m adding my bundles:

// Create manager for game data and logic
let game_data = GameDataBuilder::default()
    // Input systems bundle for input bindings
    // UI systems bundle for all entities with UI components
    .with_bundle(UiBundle::<StringBindings>::new())? /* Adding this causes a panic! */
    // Rendering systems bundle with window for 2D rendering
        // --snip--

The error is similar to when trying to create entities with unregistered components, but this is a built-in system bundle so that doesn’t make sense. Any clue as to why this isn’t working?

Possibly a bug; you could insert it yourself to get around it; I can’t remember what I did when I was using Amethyst.

Alternatively you could try and make sure you’re on the latest version of Amethyst (I’ve only used amethyst until 0.15which uses specs, so don’t know how it works with Legion).

I’m not sure how I would go about inserting it into the world since previously in the tutorial I world.registered my system-less component resources inside of my Pong game state, which I don’t seem to be entering at all before the application panics. Granted, I’m brand new to Amethyst so maybe if I were to dig through the docs I could figure out what the Hierarchy<Parent> resource is and where to find the world to add it before I enter the application. In the meantime I’ll try updating to a newer release, since I am currently running 0.15.0 while 0.15.3 is available… not exactly sure what release the documentation and tutorial is for, not to mention the examples, so perhaps that is part of the issue?

not exactly sure what release the documentation and tutorial is for, not to mention the examples, so perhaps that is part of the issue?

Most likely – I’ve text searched my copy of Amethyst / my game, and couldn’t find where the Hierarchy<Parent> is inserted.

I do recommend that you try out bevy instead of Amethyst though – I think Amethyst is on ice.