voxell-tech / bevy_motiongfx

Motion graphics creation tool in Bevy. (Highly inspired by Motion Canvas and Manim)
Apache License 2.0
169 stars 3 forks source link

Automatically play controller? #41

Closed musjj closed 6 months ago

musjj commented 7 months ago

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.

nixon-voxell commented 7 months ago

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.

musjj commented 7 months ago

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.

musjj commented 7 months ago

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?

nixon-voxell commented 6 months ago

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.

nixon-voxell commented 6 months ago

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

musjj commented 6 months ago

Yeah, I'll close it for now.