generated from NiklasEi/bevy_game_template
-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement character controller moving player
- Loading branch information
1 parent
2d4a64c
commit ab237f2
Showing
14 changed files
with
223 additions
and
57 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
( | ||
assets: | ||
[ | ||
] | ||
) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use bevy::{ | ||
ecs::component::{ComponentHooks, StorageType}, | ||
prelude::*, | ||
}; | ||
use bevy_tnua::prelude::*; | ||
use leafwing_input_manager::prelude::*; | ||
|
||
use super::action::CharacterAction; | ||
|
||
pub(super) fn plugin(app: &mut App) { | ||
app.register_type::<InsertCharacterController>(); | ||
} | ||
|
||
#[derive(Debug, Clone, Copy, Reflect)] | ||
#[reflect(Component)] | ||
struct InsertCharacterController; | ||
|
||
impl Component for InsertCharacterController { | ||
const STORAGE_TYPE: StorageType = StorageType::Table; | ||
|
||
fn register_component_hooks(hooks: &mut ComponentHooks) { | ||
hooks.on_add(|mut world, entity, _component_id| { | ||
world | ||
.commands() | ||
.entity(entity) | ||
.insert(( | ||
TnuaControllerBundle::default(), | ||
ActionState::<CharacterAction>::default(), | ||
)) | ||
.remove::<InsertCharacterController>(); | ||
}); | ||
} | ||
} |
Oops, something went wrong.