Skip to content

How can i zoom in with a Camera2dBundle? #5904

Answered by brandon-reinhart
DasLixou asked this question in Q&A
Discussion options

You must be logged in to vote

In a system, get the OrthographicProjection associated with the Camera2d and set the scale there:

fn zoom(mut query: Query<&mut OrthographicProjection, With<Camera2d>>) {
   let mut projection = query.single_mut();
   projection.scale = 5.0;
}

Spawning the bundle is the same as spawning and then inserting a bundle. Inserting a bundle is inserting several components simultaneously. When you use a bundle, it's worth looking up the payload of components that are added. For Camera2dBundle, that's here:

https://docs.rs/bevy/latest/bevy/core_pipeline/core_2d/struct.Camera2dBundle.html

You can see in the list it includes an OrthographicProjection which you can manipulate.

Replies: 1 comment

Comment options

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