Added gun sprite

This commit is contained in:
Alexey 2025-07-10 00:14:15 +03:00
commit f1529d7e58
7 changed files with 225 additions and 32 deletions

View file

@ -30,6 +30,9 @@ pub struct Player {
#[reflect(hidden)]
move_right: bool,
#[reflect(hidden)]
reset_position: bool,
#[reflect(hidden)]
yaw: f32,
@ -85,6 +88,9 @@ impl ScriptTrait for Player {
KeyCode::KeyD => {
self.move_right = is_pressed;
},
KeyCode::F1 => {
self.reset_position = is_pressed;
},
_ => (),
}
}
@ -114,6 +120,12 @@ impl ScriptTrait for Player {
}
if let Some(rigid_body) = context.scene.graph.try_get_mut_of_type::<RigidBody>(context.handle) {
if self.reset_position {
rigid_body.local_transform_mut().set_position(Vector3::new(0.0, 0.0, 0.0));
return;
}
let mut velocity = Vector3::new(0.0, 0.0, 0.0);
if self.move_forward {
velocity += look_vector;