Crates.io | bevy_gyroscope |
lib.rs | bevy_gyroscope |
version | 0.1.0 |
source | src |
created_at | 2024-11-29 18:50:05.828183 |
updated_at | 2024-11-29 18:50:05.828183 |
description | A Bevy plugin that provides gyroscope functionality. |
homepage | |
repository | https://github.com/gradddev/bevy_gyroscope |
max_upload_size | |
id | 1465935 |
size | 6,236 |
[!WARNING]
This plugin currently only supports iOS devices.
A Bevy plugin that provides gyroscope functionality.
You can add this plugin to your project using cargo:
cargo add bevy_gyroscope
Or manually add it to your Cargo.toml
:
[dependencies]
bevy_gyroscope = "0.1.0" # replace with actual version
use bevy::prelude::*;
use bevy_gyroscope::{GyroscopePlugin, Gyroscope};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
// Add the gyroscope plugin with default settings (60Hz update frequency)
.add_plugins(GyroscopePlugin::default())
.add_systems(Update, use_gyroscope_data)
.run();
}
fn use_gyroscope_data(gyroscope: Res<Gyroscope>) {
println!("Gyroscope: x={}, y={}, z={}",
gyroscope.x,
gyroscope.y,
gyroscope.z
);
}
You can customize the update frequency when adding the plugin:
.add_plugins(GyroscopePlugin { frequency: 120.0 })
The plugin provides a Gyroscope
resource that contains the rotation delta (change in rotation) for the current frame:
x
: Change in rotation around the x-axis (in radians) per framey
: Change in rotation around the y-axis (in radians) per framez
: Change in rotation around the z-axis (in radians) per frameContributions are welcome! Please feel free to submit a Pull Request.