aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
Diffstat (limited to 'rust')
-rw-r--r--rust/src/basic_die.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/rust/src/basic_die.rs b/rust/src/basic_die.rs
index 0b028b8..ffd3bff 100644
--- a/rust/src/basic_die.rs
+++ b/rust/src/basic_die.rs
@@ -75,7 +75,8 @@ impl BasicDie {
#[export]
unsafe fn _ready(&mut self, owner: &Spatial) {
- godot_print!("Player starting");
+ Input::godot_singleton().set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
+
owner.set_physics_process(true);
let search_node = | parent: &SpatialRef, name: String | {
@@ -125,11 +126,11 @@ impl BasicDie {
Some(rb) => rb.linear_velocity().length()
}
};
- godot_print!("current velocity: {}", current_vel);
// check if the velocity is less than the threshold and change input state in that case
if current_vel <= self.stopping_velocity {
self.input_state = InputState::Default;
+ godot_print!("Die stopped moving");
}
};
}
@@ -159,6 +160,16 @@ impl BasicDie {
},
_ => {}
}
+
+ let key_event = save_event.cast::<InputEventKey>();
+ match key_event {
+ Some(key_event) => {
+ if key_event.scancode() == GlobalConstants::KEY_ESCAPE {
+ Input::godot_singleton().set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+ }
+ },
+ _ => {}
+ }
}
/// this input method will be called when looking around, before taking a shot
@@ -198,7 +209,7 @@ impl BasicDie {
let mouse_event = save_event.cast::<InputEventMouseMotion>(); // get the input as mouse input
match mouse_event {
Some(motion_event) => {
- let y_mov = motion_event.relative().y * self.mouse_sensitivity.y;
+ let y_mov = motion_event.relative().y * self.shoot_sensitivity;
self.current_force = match self.current_force + y_mov {
x if x < 0.0 => 0.0,
x if x > self.max_force => self.max_force,
@@ -266,7 +277,7 @@ impl BasicDie {
None => { godot_warn!("No camera assigned!"); return; },
Some(cam) => {
// get the forward vector of the camera setting the up angle to the defined value in the editor
- let mut forward_vector = cam.assume_safe().global_transform().basis.c();
+ let mut forward_vector = -cam.assume_safe().global_transform().basis.c();
forward_vector.y = self.up_angle;
// calculate the impulse force