bevy_accelerometer

Crates.iobevy_accelerometer
lib.rsbevy_accelerometer
version0.1.0
sourcesrc
created_at2024-11-29 19:28:34.733381
updated_at2024-11-29 19:28:34.733381
descriptionA Bevy plugin that provides accelerometer functionality.
homepage
repositoryhttps://github.com/gradddev/bevy_accelerometer
max_upload_size
id1465966
size6,112
Alex Grad (gradddev)

documentation

README

Bevy Accelerometer Plugin

[!WARNING]
This plugin currently only supports iOS devices.

A Bevy plugin that provides accelerometer functionality.

Installation

You can add this plugin to your project using cargo:

cargo add bevy_accelerometer

Or manually add it to your Cargo.toml:

[dependencies]
bevy_accelerometer = "0.1.0"  # replace with actual version

Usage

use bevy::prelude::*;
use bevy_accelerometer::{AccelerometerPlugin, Accelerometer};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Add the accelerometer plugin with default settings (60Hz update frequency)
        .add_plugins(AccelerometerPlugin::default())
        .add_systems(Update, use_accelerometer_data)
        .run();
}

fn use_accelerometer_data(accelerometer: Res<Accelerometer>) {
    println!("Accelerometer: x={}, y={}, z={}", 
        accelerometer.x, 
        accelerometer.y, 
        accelerometer.z
    );
}

Custom Configuration

You can customize the update frequency when adding the plugin:

.add_plugins(AccelerometerPlugin { frequency: 120.0 })

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Commit count: 1

cargo fmt