-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from cBournhonesque/cb/projectiles
Adds basic projectiles
- Loading branch information
Showing
6 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
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,34 @@ | ||
use bevy::color::palettes::basic::BLUE; | ||
use bevy::prelude::*; | ||
use shared::projectiles::Projectile; | ||
|
||
pub(crate) struct ProjectilesPlugin; | ||
|
||
impl Plugin for ProjectilesPlugin { | ||
fn build(&self, app: &mut App) { | ||
// SYSTEMS | ||
app.add_observer(spawn_visuals); | ||
} | ||
} | ||
|
||
/// When a projectile is spawn, add visuals to it | ||
fn spawn_visuals( | ||
trigger: Trigger<OnAdd, Projectile>, | ||
mut commands: Commands, | ||
mut meshes: ResMut<Assets<Mesh>>, | ||
mut materials: ResMut<Assets<StandardMaterial>>, | ||
) { | ||
commands.entity(trigger.entity()).with_child( | ||
( | ||
Mesh3d(meshes.add(Mesh::from(Sphere { | ||
// TODO: must match the collider size | ||
radius: 0.1, | ||
..default() | ||
}))), | ||
MeshMaterial3d(materials.add(StandardMaterial { | ||
base_color: BLUE.into(), | ||
..Default::default() | ||
})), | ||
) | ||
); | ||
} |
Empty file.
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