Skip to content

How to express branching dialogue with Bevy ECS? #6510

Answered by ickshonpe
johan-overbye asked this question in Q&A
Discussion options

You must be logged in to vote

I implemented something similar for cutscenes in one of my projects, I'm not sure how practical it is etc though.
A more granular design might fit more naturally with Bevy's ECS. For instance, the components like Character, Statement, Junction, Choice and Junction could be empty Marker Components, and Name, Text, Speaker, Next and Choices could be POD newtype components.

To access the individual entities and their components you can use queries:

#[derive(Resource)]
struct CurrentNarrationNode(Option<Entity>);

fn statement_system(
    mut node: ResMut<CurrentNarrationNode>,  
    statements: Query<&Statement>,
    characters: Query<&Character>,
) {
    if let Some(statement) = node.0.and_…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@nicopap
Comment options

nicopap Nov 7, 2022
Collaborator

@johan-overbye
Comment options

@ickshonpe
Comment options

@johan-overbye
Comment options

Answer selected by johan-overbye
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants