#bevy #fps #bevy-engine #controller #bevy-plugin

bevy_fps_controller

Bevy plugin that adds a Source engine inspired FPS movement controller

10 releases

0.2.0-dev Mar 11, 2023
0.1.8-dev Feb 28, 2023
0.1.5-dev Dec 11, 2022
0.1.4-dev Nov 20, 2022
0.1.2-dev Aug 8, 2022

#207 in Game dev

Download history 27/week @ 2022-12-06 10/week @ 2022-12-13 10/week @ 2022-12-20 2/week @ 2022-12-27 3/week @ 2023-01-03 10/week @ 2023-01-10 5/week @ 2023-01-17 10/week @ 2023-01-24 6/week @ 2023-01-31 35/week @ 2023-02-07 41/week @ 2023-02-14 13/week @ 2023-02-21 22/week @ 2023-02-28 16/week @ 2023-03-07 3/week @ 2023-03-14 20/week @ 2023-03-21

62 downloads per month

MIT/Apache

280KB
397 lines

Rust crates.io

Bevy FPS Controller

Inspired from Source engine movement, this plugin implements movement suitable for FPS games.

⚠️ Feedback requested! Still in early stages, feel free to make issues/PRs

Features

  • Air strafing and bunny hopping (hold down jump key)
  • Support for sloped ground
  • Crouching (prevents falling off ledges), sprinting
  • Noclip mode
  • Configurable settings

Examples

See main.rs

cargo run --example minimal
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;

use bevy_fps_controller::controller::*;

fn main() {
    App::new()
        ...
        .add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
        .add_plugin(FpsControllerPlugin)
        .add_startup_system(setup)
        ...
}

fn setup(mut commands: Commands, ...) {
    ...
    commands.spawn((
        Collider::capsule(Vec3::Y * 0.5, Vec3::Y * 1.5, 0.5),
        Friction {
            coefficient: 0.0,
            combine_rule: CoefficientCombineRule::Min,
        },
        Restitution {
            coefficient: 0.0,
            combine_rule: CoefficientCombineRule::Min,
        },
        ActiveEvents::COLLISION_EVENTS,
        Velocity::zero(),
        RigidBody::Dynamic,
        Sleeping::disabled(),
        LockedAxes::ROTATION_LOCKED,
        AdditionalMassProperties::Mass(1.0),
        GravityScale(0.0),
        Ccd { enabled: true }, // Prevent clipping when going fast
        TransformBundle::from_transform(Transform::from_xyz(0.0, 3.0, 0.0)),
        LogicalPlayer(0),
        FpsControllerInput {
            pitch: -TAU / 12.0,
            yaw: TAU * 5.0 / 8.0,
            ..default()
        },
        FpsController { ..default() }
    ));
    commands.spawn((
        Camera3dBundle::default(),
        RenderPlayer(0),
    ));
    ...
}

Demo

https://user-images.githubusercontent.com/20666629/221995601-2ec352fe-a8b0-4f8c-9a81-beaf898b2b41.mp4

Used by my other project: https://github.com/qhdwight/voxel-game-rs

Dependencies

~27–62MB
~1M SLoC