Closed Joakker closed 6 months ago
There's an enabled
attribute to the RtsCameraControls
component. Is that not suitable?
Can toggle like this:
fn toggle_camera_controls_system(
key_input: Res<ButtonInput<KeyCode>>,
mut controls_q: Query<&mut RtsCameraControls>,
) {
if key_input.just_pressed(KeyCode::KeyT) {
for mut controls in controls_q.iter_mut() {
controls.enabled = !controls.enabled;
}
}
}
Oh sorry, I'm dumb. I hadn't seen that
The problem
I'll explain what I want to do: When focusing on the game's UI, the camera shouldn't react to the player's input. For example, if there's a side panel that the player must click, the camera shouldn't move when approaching the window edge. If there's a list to scroll through, the camera shouldn't zoom when the mouse is over that list.
Possible solution
Provide a resource, for example
That you can add when you need to keep the camera still, and then in
src/controller.rs
That way, while the resource exists, the camera won't react to the player's input, and you can remove the resource when defocusing the UI.