Skip to content
Discussion options

You must be logged in to vote

Don't be discouraged. This is a pretty common beginner mistake to make. You're moving the circle, but also the camera!

To move only the circle, you can:

Create a struct that we'll use a "marker component."

#[derive(Component)]
struct Circle;

Add it to your circle when you spawn it.

commands.spawn((
    MaterialMesh2dBundle {
        mesh: meshes.add(shape::Circle::new(50.).into()).into(),
        material: materials.add(ColorMaterial::from(Color::PURPLE)),
        transform: Transform::from_translation(Vec3::new(-150., 0., 0.)),
        ..default()
    },
    Circle
));

Finally, add a query filter to your move_circle system.

fn move_circle(mut circle: Query<&mut Transform, With<Circle>>, t…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bobfp
Comment options

@chaserileyroberts
Comment options

Answer selected by bobfp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
A-Transform Translations, rotations and scales
3 participants