Add punch animation as well
This commit is contained in:
parent
fb799acdbe
commit
b53b6289bd
@ -19,7 +19,7 @@ font_color = Color(1, 0, 0, 1)
|
|||||||
outline_size = 10
|
outline_size = 10
|
||||||
outline_color = Color(0, 0, 0, 1)
|
outline_color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
[node name="player" type="LocalPlayer" unique_id=863055906 node_paths=PackedStringArray("camera", "soldier_mesh", "collider", "effects", "dead_cam_target", "respawn_label", "camera_origin", "weapon_node", "pause_panel", "exit_to_lobby", "settings_panel", "scoreboard", "chatbox", "health_label")]
|
[node name="player" type="LocalPlayer" unique_id=863055906 node_paths=PackedStringArray("camera", "soldier_mesh", "collider", "effects", "dead_cam_target", "respawn_label", "camera_origin", "weapon_node", "pause_panel", "exit_to_lobby", "settings_panel", "scoreboard", "chatbox", "health_label", "hit_sound")]
|
||||||
look_sensitivity = 1.5
|
look_sensitivity = 1.5
|
||||||
camera = NodePath("camera_3d")
|
camera = NodePath("camera_3d")
|
||||||
move_speed = 5.0
|
move_speed = 5.0
|
||||||
@ -36,7 +36,9 @@ settings_panel = NodePath("settings")
|
|||||||
scoreboard = NodePath("scoreboard")
|
scoreboard = NodePath("scoreboard")
|
||||||
chatbox = NodePath("chat_box")
|
chatbox = NodePath("chat_box")
|
||||||
health_label = NodePath("health_label")
|
health_label = NodePath("health_label")
|
||||||
|
hit_sound = NodePath("hit_sound")
|
||||||
health = 100
|
health = 100
|
||||||
|
punch_cooldown = 1.0
|
||||||
collision_mask = 4
|
collision_mask = 4
|
||||||
|
|
||||||
[node name="camera_3d" type="Camera3D" parent="." unique_id=1773137418]
|
[node name="camera_3d" type="Camera3D" parent="." unique_id=1773137418]
|
||||||
|
|||||||
@ -38,6 +38,7 @@ soldier_mesh = NodePath("soldier_m")
|
|||||||
collider = NodePath("collision_shape_3d")
|
collider = NodePath("collision_shape_3d")
|
||||||
effects = NodePath("effects")
|
effects = NodePath("effects")
|
||||||
health = 100
|
health = 100
|
||||||
|
punch_cooldown = 1.0
|
||||||
spectator_camera = NodePath("spectate_root/spectate_camera")
|
spectator_camera = NodePath("spectate_root/spectate_camera")
|
||||||
camera_origin = NodePath("camera_origin")
|
camera_origin = NodePath("camera_origin")
|
||||||
name_label = NodePath("name_label")
|
name_label = NodePath("name_label")
|
||||||
|
|||||||
@ -431,9 +431,6 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn change_map_selection(&mut self, map_idx: u8, emit: bool) {
|
pub fn change_map_selection(&mut self, map_idx: u8, emit: bool) {
|
||||||
if self.selected_map_idx == map_idx {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.selected_map_idx = map_idx;
|
self.selected_map_idx = map_idx;
|
||||||
if let Some(map) = self.maps.get(map_idx as usize) {
|
if let Some(map) = self.maps.get(map_idx as usize) {
|
||||||
self.selected_map = Some(map);
|
self.selected_map = Some(map);
|
||||||
|
|||||||
@ -168,6 +168,10 @@ impl IPlayer for LocalPlayer {
|
|||||||
|
|
||||||
fn try_punch(&mut self, to: Vector3, deal_damage: bool) -> bool {
|
fn try_punch(&mut self, to: Vector3, deal_damage: bool) -> bool {
|
||||||
if self.punch_cd_remaining <= 0. {
|
if self.punch_cd_remaining <= 0. {
|
||||||
|
if let Some(weapon) = &mut self.weapon {
|
||||||
|
weapon.set_position(Vector3::FORWARD);
|
||||||
|
weapon.set_rotation(Vector3::UP);
|
||||||
|
}
|
||||||
self.punch_cd_remaining = self.punch_cooldown;
|
self.punch_cd_remaining = self.punch_cooldown;
|
||||||
self.try_punch_common(to, deal_damage)
|
self.try_punch_common(to, deal_damage)
|
||||||
} else {
|
} else {
|
||||||
@ -328,6 +332,7 @@ impl ICharacterBody3D for LocalPlayer {
|
|||||||
|
|
||||||
fn process(&mut self, delta: f64) {
|
fn process(&mut self, delta: f64) {
|
||||||
self.time_passed += delta;
|
self.time_passed += delta;
|
||||||
|
self.punch_cd_remaining -= delta;
|
||||||
|
|
||||||
if self.is_dead {
|
if self.is_dead {
|
||||||
self.dead_for += delta;
|
self.dead_for += delta;
|
||||||
@ -426,10 +431,11 @@ impl ICharacterBody3D for LocalPlayer {
|
|||||||
let prev_weapon_pos = weapon.get_position();
|
let prev_weapon_pos = weapon.get_position();
|
||||||
let new_y = prev_weapon_pos.y.lerp(target_y as f32, 0.2);
|
let new_y = prev_weapon_pos.y.lerp(target_y as f32, 0.2);
|
||||||
let new_x = prev_weapon_pos.x.lerp(target_x as f32, 0.2);
|
let new_x = prev_weapon_pos.x.lerp(target_x as f32, 0.2);
|
||||||
|
let new_z = prev_weapon_pos.z.lerp(0., 0.2);
|
||||||
let new_weapon_pos = Vector3 {
|
let new_weapon_pos = Vector3 {
|
||||||
y: new_y,
|
y: new_y,
|
||||||
x: new_x,
|
x: new_x,
|
||||||
..prev_weapon_pos
|
z: new_z,
|
||||||
};
|
};
|
||||||
weapon.set_position(new_weapon_pos);
|
weapon.set_position(new_weapon_pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -235,7 +235,7 @@ impl<T: IPlayer + ICharacterBody3D + WithBaseField> PlayerCommon for T {
|
|||||||
self.run_deferred(move |s| {
|
self.run_deferred(move |s| {
|
||||||
shootable.dyn_bind_mut().on_shoot(
|
shootable.dyn_bind_mut().on_shoot(
|
||||||
DamageSource::Player(s.get_player_id().unwrap_or(0)),
|
DamageSource::Player(s.get_player_id().unwrap_or(0)),
|
||||||
500,
|
100,
|
||||||
delta.normalized(),
|
delta.normalized(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -242,6 +242,8 @@ impl ICharacterBody3D for RemotePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn process(&mut self, delta: f64) {
|
fn process(&mut self, delta: f64) {
|
||||||
|
self.punch_cd_remaining -= delta;
|
||||||
|
|
||||||
if self.is_dead {
|
if self.is_dead {
|
||||||
self.dead_for += delta;
|
self.dead_for += delta;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user