Skip to content

What's the proper way to modify capsule collider values like radius or height? #444

Answered by VergilUa
VergilUa asked this question in Q&A
Discussion options

You must be logged in to vote

For the future readers:
Digged a bunch of Discord questions and it seems like setting collider as a component is the way to do this.
Views are most-likely used for the future editor / inspector and reflecting values;

This works:

pub fn update_player_cc_values(
    mut commands: Commands,
    mut player_query: Query<(Entity, &mut CCSettings, &mut Collider)>){

    for (entity, mut settings, mut collider) in player_query.iter_mut() {
        if !settings.dirty
        {
            continue;
        }

        if let Some(_capsule) = collider.as_capsule() {
            commands.entity(entity).insert(Collider::capsule_y(settings.height * 0.5, settings.radius));

            println!("Changed…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by VergilUa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant