Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-running the same example crashes on option selection #219

Open
PatrickChodowski opened this issue Dec 22, 2024 · 1 comment
Open

Re-running the same example crashes on option selection #219

PatrickChodowski opened this issue Dec 22, 2024 · 1 comment

Comments

@PatrickChodowski
Copy link

I am running the same ("hello world" example) dialogue on every interaction with entity, basically running this:

        let mut dialogue_runner = project.create_dialogue_runner();
        dialogue_runner.start_node("HelloWorld");
        commands.spawn(dialogue_runner);

... once I click on other character in the game. It works well on the first run, but crashes on the repeat no matter which option I choose (and doesn't matter If I selected it before too) with

`Result::unwrap()` on an `Err` value: Can't select option 1: the dialogue is currently not running. Please call `DialogueRunner::continue_in_next_update()` only after receiving a `PresentOptionsEvent`.

Is there something I am missing like maybe closing the previous dialogue properly?

btw. I am using already the version from bevy0.15 PR #217 but this piece of code seems to not be updated by this change so naively I assume this issue was there before :)

@PatrickChodowski
Copy link
Author

I found a way to avoid it, by despawning the dialogue entity after it finished running.

fn track(
    mut commands: Commands,
    drs:          Query<(Entity, &DialogueRunner), Changed<DialogueRunner>>
){
    for (entity, dr) in drs.iter(){
        if !dr.is_running(){
            commands.entity(entity).despawn_recursive();
        }
    }
}

So technically its not an issue but maybe dialogue should despawn on its own after it finished running?

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

No branches or pull requests

1 participant