fix: player fires bullets only when cursor grabbed
This commit is contained in:
parent
216a50ddb8
commit
490fef5393
@ -5,6 +5,7 @@ use avian3d::prelude::*;
|
|||||||
|
|
||||||
use crate::physics::BulletFiredEvent;
|
use crate::physics::BulletFiredEvent;
|
||||||
use crate::ui::camera::CameraController;
|
use crate::ui::camera::CameraController;
|
||||||
|
use crate::ui::cursor::CursorGrabState;
|
||||||
|
|
||||||
pub struct PlayerPlugin;
|
pub struct PlayerPlugin;
|
||||||
|
|
||||||
@ -13,7 +14,10 @@ impl Plugin for PlayerPlugin
|
|||||||
fn build(&self, app: &mut App)
|
fn build(&self, app: &mut App)
|
||||||
{
|
{
|
||||||
app.add_systems(Startup, setup_player);
|
app.add_systems(Startup, setup_player);
|
||||||
app.add_systems(PreUpdate, do_shoot_on_left_click.run_if(on_event::<MouseButtonInput>));
|
app.add_systems(Update, do_shoot_on_left_click
|
||||||
|
.run_if(in_state(CursorGrabState(true)))
|
||||||
|
.run_if(on_event::<MouseButtonInput>)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ fn main()
|
|||||||
{
|
{
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins(DefaultPlugins);
|
app.add_plugins(DefaultPlugins);
|
||||||
|
app.add_plugins(util::UtilPlugins);
|
||||||
app.add_plugins(ui::UiPlugins);
|
app.add_plugins(ui::UiPlugins);
|
||||||
app.add_plugins(physics::PhysicsPlugins);
|
app.add_plugins(physics::PhysicsPlugins);
|
||||||
app.add_plugins(game::GamePlugin);
|
app.add_plugins(game::GamePlugin);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user