diff --git a/examples/mobile/src/lib.rs b/examples/mobile/src/lib.rs index 45a89a076c8ac..87c815dfb42b6 100644 --- a/examples/mobile/src/lib.rs +++ b/examples/mobile/src/lib.rs @@ -2,7 +2,7 @@ use bevy::{ color::palettes::basic::*, - input::touch::TouchPhase, + input::{gestures::RotationGesture, touch::TouchPhase}, prelude::*, window::{AppLifecycle, WindowMode}, }; @@ -15,6 +15,9 @@ fn main() { primary_window: Some(Window { resizable: false, mode: WindowMode::BorderlessFullscreen, + // on iOS, gestures must be enabled. + // This doesn't work on Android + recognize_rotation_gesture: true, ..default() }), ..default() @@ -35,6 +38,7 @@ fn touch_camera( mut touches: EventReader, mut camera: Query<&mut Transform, With>, mut last_position: Local>, + mut rotations: EventReader, ) { let window = windows.single(); @@ -55,6 +59,12 @@ fn touch_camera( } *last_position = Some(touch.position); } + /// Rotation gestures only work on iOS + for rotation in rotations.read() { + let mut transform = camera.single_mut(); + let forward = transform.forward(); + transform.rotate_axis(forward, rotation.0 / 10.0) + } } /// set up a simple 3D scene