Move splorch to player effects, add hit sound
This commit is contained in:
parent
600f5b4986
commit
19fc76bf77
@ -10,13 +10,13 @@ glow_enabled = true
|
|||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_oh8vq"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_oh8vq"]
|
||||||
|
|
||||||
[node name="player" type="LocalPlayer" unique_id=863055906 node_paths=PackedStringArray("camera", "soldier_mesh", "collider", "splorch", "dead_cam_target", "respawn_label", "ball_origin", "weapon_node", "pause_panel", "exit_to_lobby", "settings_panel", "scoreboard")]
|
[node name="player" type="LocalPlayer" unique_id=863055906 node_paths=PackedStringArray("camera", "soldier_mesh", "collider", "effects", "dead_cam_target", "respawn_label", "ball_origin", "weapon_node", "pause_panel", "exit_to_lobby", "settings_panel", "scoreboard")]
|
||||||
look_sensitivity = 1.5
|
look_sensitivity = 1.5
|
||||||
camera = NodePath("camera_3d")
|
camera = NodePath("camera_3d")
|
||||||
move_speed = 5.0
|
move_speed = 5.0
|
||||||
soldier_mesh = NodePath("soldier_m")
|
soldier_mesh = NodePath("soldier_m")
|
||||||
collider = NodePath("collision_shape_3d2")
|
collider = NodePath("collision_shape_3d2")
|
||||||
splorch = NodePath("splorch")
|
effects = NodePath("effects")
|
||||||
dead_cam_target = NodePath("dead_camera_target")
|
dead_cam_target = NodePath("dead_camera_target")
|
||||||
respawn_label = NodePath("respawn_label")
|
respawn_label = NodePath("respawn_label")
|
||||||
ball_origin = NodePath("camera_3d")
|
ball_origin = NodePath("camera_3d")
|
||||||
@ -44,7 +44,7 @@ transform = Transform3D(-0.5, 0, -4.371139e-08, 0, 0.5, 0, 4.371139e-08, 0, -0.5
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
shape = SubResource("CapsuleShape3D_oh8vq")
|
shape = SubResource("CapsuleShape3D_oh8vq")
|
||||||
|
|
||||||
[node name="splorch" parent="." unique_id=986677517 instance=ExtResource("2_ywmwa")]
|
[node name="effects" parent="." unique_id=986677517 instance=ExtResource("2_ywmwa")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.16157162, 1.4223524, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.16157162, 1.4223524, 0)
|
||||||
|
|
||||||
[node name="dead_camera_target" type="Node3D" parent="." unique_id=559969559]
|
[node name="dead_camera_target" type="Node3D" parent="." unique_id=559969559]
|
||||||
|
|||||||
@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1cgct"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1cgct"]
|
||||||
|
|
||||||
[node name="player" type="RemotePlayer" unique_id=845968872 node_paths=PackedStringArray("soldier_mesh", "collider", "splorch", "spectator_camera", "ball_origin", "name_label")]
|
[node name="player" type="RemotePlayer" unique_id=845968872 node_paths=PackedStringArray("soldier_mesh", "collider", "effects", "spectator_camera", "ball_origin", "name_label")]
|
||||||
move_speed = 5.0
|
move_speed = 5.0
|
||||||
soldier_mesh = NodePath("soldier_m")
|
soldier_mesh = NodePath("soldier_m")
|
||||||
collider = NodePath("collision_shape_3d")
|
collider = NodePath("collision_shape_3d")
|
||||||
splorch = NodePath("gpu_particles_3d")
|
effects = NodePath("effects")
|
||||||
health = 100
|
health = 100
|
||||||
spectator_camera = NodePath("spectate_root/spectate_camera")
|
spectator_camera = NodePath("spectate_root/spectate_camera")
|
||||||
ball_origin = NodePath("ball_origin")
|
ball_origin = NodePath("ball_origin")
|
||||||
@ -24,7 +24,7 @@ transform = Transform3D(-0.5, 0, -4.371139e-08, 0, 0.5, 0, 4.371139e-08, 0, -0.5
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
shape = SubResource("CapsuleShape3D_1cgct")
|
shape = SubResource("CapsuleShape3D_1cgct")
|
||||||
|
|
||||||
[node name="gpu_particles_3d" parent="." unique_id=986677517 instance=ExtResource("2_orxjf")]
|
[node name="effects" parent="." unique_id=986677517 instance=ExtResource("2_orxjf")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4540546, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4540546, 0)
|
||||||
|
|
||||||
[node name="spectate_root" type="Node3D" parent="." unique_id=624336254]
|
[node name="spectate_root" type="Node3D" parent="." unique_id=624336254]
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
[gd_scene format=3 uid="uid://cl66unms2gim0"]
|
[gd_scene format=3 uid="uid://cl66unms2gim0"]
|
||||||
|
|
||||||
|
[ext_resource type="AudioStream" uid="uid://bfg31e3s4jv8c" path="res://assets/Hit.mp3" id="1_2hdmt"]
|
||||||
|
|
||||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_1cgct"]
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_1cgct"]
|
||||||
particle_flag_align_y = true
|
particle_flag_align_y = true
|
||||||
direction = Vector3(0, 1, 0)
|
direction = Vector3(0, 1, 0)
|
||||||
@ -23,7 +25,11 @@ section_length = 0.1
|
|||||||
section_rings = 10
|
section_rings = 10
|
||||||
curve = SubResource("Curve_yli5f")
|
curve = SubResource("Curve_yli5f")
|
||||||
|
|
||||||
[node name="gpu_particles_3d" type="GPUParticles3D" unique_id=986677517]
|
[node name="player_effects" type="PlayerEffects" unique_id=1493455892 node_paths=PackedStringArray("splorch", "hit_sound")]
|
||||||
|
splorch = NodePath("splorch")
|
||||||
|
hit_sound = NodePath("hit_sound")
|
||||||
|
|
||||||
|
[node name="splorch" type="GPUParticles3D" parent="." unique_id=986677517]
|
||||||
emitting = false
|
emitting = false
|
||||||
amount = 20
|
amount = 20
|
||||||
one_shot = true
|
one_shot = true
|
||||||
@ -32,3 +38,7 @@ trail_enabled = true
|
|||||||
trail_lifetime = 0.5
|
trail_lifetime = 0.5
|
||||||
process_material = SubResource("ParticleProcessMaterial_1cgct")
|
process_material = SubResource("ParticleProcessMaterial_1cgct")
|
||||||
draw_pass_1 = SubResource("TubeTrailMesh_wwb7k")
|
draw_pass_1 = SubResource("TubeTrailMesh_wwb7k")
|
||||||
|
|
||||||
|
[node name="hit_sound" type="AudioStreamPlayer3D" parent="." unique_id=345049143]
|
||||||
|
stream = ExtResource("1_2hdmt")
|
||||||
|
volume_db = 80.0
|
||||||
|
|||||||
26
rust/src/player/effects.rs
Normal file
26
rust/src/player/effects.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
use godot::{
|
||||||
|
classes::{AudioStreamPlayer3D, GpuParticles3D},
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(GodotClass)]
|
||||||
|
#[class(base=Node3D, init)]
|
||||||
|
pub struct PlayerEffects {
|
||||||
|
#[export]
|
||||||
|
splorch: Option<Gd<GpuParticles3D>>,
|
||||||
|
#[export]
|
||||||
|
hit_sound: Option<Gd<AudioStreamPlayer3D>>,
|
||||||
|
|
||||||
|
base: Base<Node3D>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PlayerEffects {
|
||||||
|
pub fn death(&mut self) {
|
||||||
|
if let Some(splorch) = &mut self.splorch {
|
||||||
|
splorch.set_emitting(true);
|
||||||
|
}
|
||||||
|
if let Some(sfx) = &mut self.hit_sound {
|
||||||
|
sfx.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -23,12 +23,14 @@ use crate::{
|
|||||||
util::{NetVector3, cast_ray},
|
util::{NetVector3, cast_ray},
|
||||||
},
|
},
|
||||||
player::{
|
player::{
|
||||||
|
effects::PlayerEffects,
|
||||||
soldier_mesh::SoldierMesh,
|
soldier_mesh::SoldierMesh,
|
||||||
weapon::{BallWeapon, Raygun, Weapon, WeaponType},
|
weapon::{BallWeapon, Raygun, Weapon, WeaponType},
|
||||||
},
|
},
|
||||||
ui::{cli::CommandLinePanel, settings::SettingsPanel},
|
ui::{cli::CommandLinePanel, settings::SettingsPanel},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub mod effects;
|
||||||
pub mod player_hand_remover;
|
pub mod player_hand_remover;
|
||||||
pub mod soldier_mesh;
|
pub mod soldier_mesh;
|
||||||
pub mod weapon;
|
pub mod weapon;
|
||||||
@ -189,7 +191,7 @@ pub struct LocalPlayer {
|
|||||||
#[export]
|
#[export]
|
||||||
collider: Option<Gd<CollisionShape3D>>,
|
collider: Option<Gd<CollisionShape3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
splorch: Option<Gd<GpuParticles3D>>,
|
effects: Option<Gd<PlayerEffects>>,
|
||||||
#[export]
|
#[export]
|
||||||
dead_cam_target: Option<Gd<Node3D>>,
|
dead_cam_target: Option<Gd<Node3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
@ -342,8 +344,8 @@ impl IPlayer for LocalPlayer {
|
|||||||
if let Some(mut collider) = self.collider.take() {
|
if let Some(mut collider) = self.collider.take() {
|
||||||
collider.queue_free();
|
collider.queue_free();
|
||||||
}
|
}
|
||||||
if let Some(splorch) = &mut self.splorch {
|
if let Some(effects) = &mut self.effects {
|
||||||
splorch.set_emitting(true);
|
effects.bind_mut().death();
|
||||||
}
|
}
|
||||||
if let Some(mut weapon) = self.weapon.take() {
|
if let Some(mut weapon) = self.weapon.take() {
|
||||||
weapon.queue_free();
|
weapon.queue_free();
|
||||||
@ -659,7 +661,7 @@ pub struct RemotePlayer {
|
|||||||
#[export]
|
#[export]
|
||||||
collider: Option<Gd<CollisionShape3D>>,
|
collider: Option<Gd<CollisionShape3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
splorch: Option<Gd<GpuParticles3D>>,
|
effects: Option<Gd<PlayerEffects>>,
|
||||||
#[export]
|
#[export]
|
||||||
health: i32,
|
health: i32,
|
||||||
#[export]
|
#[export]
|
||||||
@ -796,8 +798,8 @@ impl IPlayer for RemotePlayer {
|
|||||||
if let Some(mut collider) = self.collider.take() {
|
if let Some(mut collider) = self.collider.take() {
|
||||||
collider.queue_free();
|
collider.queue_free();
|
||||||
}
|
}
|
||||||
if let Some(splorch) = &mut self.splorch {
|
if let Some(effects) = &mut self.effects {
|
||||||
splorch.set_emitting(true);
|
effects.bind_mut().death();
|
||||||
}
|
}
|
||||||
if let Some(mut name) = self.name_label.take() {
|
if let Some(mut name) = self.name_label.take() {
|
||||||
name.queue_free();
|
name.queue_free();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user