voxell-tech/bevy_motiongfx

Automatically play controller?

musjj opened this issue · 6 comments

Right now the following system is necessary, if you want your animation to actually play:

fn play_controller(time: Res<Time>, mut controller_query: Query<&mut SequenceController>) {
    for mut controller in &mut controller_query {
        controller.target_time += time.delta_seconds();
    }
}

I think the more user-friendly approach is to have the controller automatically play and let the user pause/seek it only if they want to.

yeah that would be possible, but I want to give users more control over how the animation would be played, maybe we can create a custom system or plugin for it and users can choose to opt-in or not.

Or do we leave this control completely to the users themselves? Cuz I was thinking like, it only needs to be setup once haha.

Edit: The main reason being that I was aware that in the game dev world, people would need alot of customizations. But I also understand some people would just want to use it to create animations quickly.

I think automatically playing is a way better default. But there should also be a way to manually control it, if the user wants to.

Maybe something like:

#[derive(Default)]
enum ControllerMode {
    #[default]
    Auto,
    Manual,
}

commands.spawn(SequencePlayerBundle {
    sequence,
    sequence_controller: SequenceController {
        mode: ControllerMode::Manual,
        ..default()
    },
    ..default()
});

Or maybe with a helper method:

commands.spawn(
    (SequencePlayerBundle {
        sequence,
        ..default()
    })
    .with_manual(),
);

Not sure what's the most ergonomic approach.

It looks like that you can actually make it automatically play:

commands.spawn(SequencePlayerBundle {
    sequence,
    sequence_player: SequencePlayer { time_scale: 1.0 },
    ..default()
});

Because of this system:

https://github.com/nixon-voxell/bevy_motiongfx/blob/c109d31da471598ea3168fc49613d4658a817a95/crates/motiongfx_core/src/sequence.rs#L238-L249

SequencePlayer defaults to 0.0 for its time_scale which is why it doesn't play by default.

I'm kinda confused, when was this added? I guess this issue can be closed?

Oh this was the component to control the sequence haha, the time_scale default to 0.0 is actually because I did not do anything fancy and just #[derive(Default)] for the component hahaha.

If you think that solves the issue (which I agree) I guessed it can be closed.

Yeah, I'll close it for now.