testing
This commit is contained in:
@@ -1,9 +1,29 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::components::{character_controller::CharacterMotion, tags::Player};
|
||||
|
||||
pub struct PlayerPlugin;
|
||||
|
||||
impl Plugin for PlayerPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
todo!()
|
||||
app.add_systems(PreUpdate, keyboard_input);
|
||||
}
|
||||
}
|
||||
|
||||
fn keyboard_input(key: Res<ButtonInput<KeyCode>>, mut player: Single<&mut CharacterMotion, With<Player>>) {
|
||||
let mut move_vec = Vec3::ZERO;
|
||||
|
||||
if key.pressed(KeyCode::KeyW) {
|
||||
move_vec.z = -1.0;
|
||||
} else if key.pressed(KeyCode::KeyS) {
|
||||
move_vec.z = 1.0;
|
||||
}
|
||||
|
||||
if key.pressed(KeyCode::KeyA) {
|
||||
move_vec.x = -1.0;
|
||||
} else if key.pressed(KeyCode::KeyD) {
|
||||
move_vec.x = 1.0;
|
||||
}
|
||||
|
||||
player.0 = move_vec;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user