Make shotgun prettier and add shotgun sounds

This commit is contained in:
Sofia 2026-07-24 20:03:44 +03:00
parent 678268642b
commit 430de3e1f1
8 changed files with 95 additions and 16 deletions

View File

@ -4,5 +4,6 @@
- [Hit](godot/raw_assets/sfx/Hit.mp3)
- [Footstep sounds on Tree Trunk](godot/raw_assets/sfx/footsteps/) via [zapsplat](https://www.zapsplat.com/sound-effect-packs/footsteps-on-fallen-tree-trunk)
- [Announcer sounds](godot/raw_assets/sfx/announcer/) by [TripleSnail](https://opengameart.org/content/announcer-kill-sounds)
- [Gun sounds (shotgun)](godot/raw_assets/sfx/gun_sounds/) by [Michel Baradari](https://opengameart.org/content/chaingun-pistol-rifle-shotgun-shots)
- [Soldier model and rig](godot/raw_assets/Soldier/) by [Casti_131](https://opengameart.org/content/low-poly-soldier-with-weapons)
- [Torment Textures](godot/maps/textures) (`str_*` files) by [Bradley D. (strideh.itch.io)](https://strideh.itch.io)

Binary file not shown.

@ -1 +1 @@
Subproject commit dbf06e89c61d33cf4dc4fede7acd31d34122dd52
Subproject commit b706f8fb162116a401080de777588e6ddd322875

View File

@ -1,20 +1,77 @@
[gd_scene format=3 uid="uid://deyfeiqyi0wmj"]
[ext_resource type="PackedScene" uid="uid://ctslratcr8h6v" path="res://scenes/player/raygun_beam.tscn" id="1_0xpw2"]
[ext_resource type="AudioStream" uid="uid://bcclq2sv7k0x3" path="res://raw_assets/sfx/gun_sounds/shotgun_compressed.mp3" id="1_pyt38"]
[ext_resource type="PackedScene" uid="uid://b8nwd3323kwlc" path="res://mesh/shotgun.tscn" id="3_0xpw2"]
[ext_resource type="AudioStream" uid="uid://bq553wxrelpdr" path="res://raw_assets/sfx/LaserWithRecoveryEditedCompressed.mp3" id="3_8oj30"]
[node name="shotgun" type="Shotgun" unique_id=786130999 node_paths=PackedStringArray("sound_emitter", "bullet_source")]
[sub_resource type="Gradient" id="Gradient_0xpw2"]
[sub_resource type="GradientTexture1D" id="GradientTexture1D_1igus"]
gradient = SubResource("Gradient_0xpw2")
[sub_resource type="Curve" id="Curve_ijfqk"]
_limits = [0.0, 5.0, 0.0, 1.0]
_data = [Vector2(0, 5), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_e0xt8"]
curve = SubResource("Curve_ijfqk")
[sub_resource type="Curve" id="Curve_kp6qq"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_x6b26"]
curve = SubResource("Curve_kp6qq")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_1cgct"]
lifetime_randomness = 0.5
particle_flag_align_y = true
direction = Vector3(0, 0, -1)
initial_velocity_min = 10.0
initial_velocity_max = 20.0
scale_curve = SubResource("CurveTexture_x6b26")
color = Color(1, 0.38039216, 0, 1)
color_ramp = SubResource("GradientTexture1D_1igus")
emission_curve = SubResource("CurveTexture_e0xt8")
[sub_resource type="Curve" id="Curve_yli5f"]
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.14107144, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 3
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ybahf"]
vertex_color_use_as_albedo = true
rim_enabled = true
rim_tint = 1.0
use_particle_trails = true
[sub_resource type="TubeTrailMesh" id="TubeTrailMesh_wwb7k"]
material = SubResource("StandardMaterial3D_ybahf")
radius = 0.1
curve = SubResource("Curve_yli5f")
[node name="shotgun" type="Shotgun" unique_id=786130999 node_paths=PackedStringArray("sound_emitter", "vfx")]
sound_emitter = NodePath("sound_emitter")
bullet_prefab = ExtResource("1_0xpw2")
bullet_source = NodePath("bullet_source")
cooldown = 1.5
vfx = NodePath("gpu_particles_3d")
cooldown = 1.0
[node name="sound_emitter" type="AudioStreamPlayer3D" parent="." unique_id=1572422640]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8420726, 0)
stream = ExtResource("3_8oj30")
stream = ExtResource("1_pyt38")
[node name="bullet_source" type="Node3D" parent="." unique_id=211401237]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.36108458, -1.490972)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.36108458, -1.2375934)
[node name="Shotgun" parent="." unique_id=1412770732 instance=ExtResource("3_0xpw2")]
[node name="gpu_particles_3d" type="GPUParticles3D" parent="." unique_id=898123062]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.2958451, -1.2305822)
emitting = false
amount = 64
lifetime = 0.2
one_shot = true
explosiveness = 1.0
local_coords = true
trail_enabled = true
trail_lifetime = 0.09999999999999999
process_material = SubResource("ParticleProcessMaterial_1cgct")
draw_pass_1 = SubResource("TubeTrailMesh_wwb7k")

View File

@ -83,9 +83,10 @@ impl Ball {
#[godot_dyn]
impl Shootable for Ball {
fn on_shoot(&mut self, _: DamageSource, _: i32, dir: Vector3) {
fn on_shoot(&mut self, _: DamageSource, damage: i32, dir: Vector3) {
let prev_velocity = self.base().get_linear_velocity();
let force = damage as f32 / 10.;
self.base_mut()
.set_linear_velocity(prev_velocity + dir * 10.);
.set_linear_velocity(prev_velocity + dir * force);
}
}

View File

@ -1,6 +1,9 @@
use std::{collections::HashSet, f32::consts::PI};
use godot::{classes::AudioStreamPlayer3D, prelude::*};
use godot::{
classes::{AudioStreamPlayer3D, GpuParticles3D},
prelude::*,
};
use serde::{Deserialize, Serialize};
use crate::{
@ -132,9 +135,7 @@ pub struct Shotgun {
#[export]
sound_emitter: Option<Gd<AudioStreamPlayer3D>>,
#[export]
bullet_prefab: Option<Gd<PackedScene>>,
#[export]
bullet_source: Option<Gd<Node3D>>,
vfx: Option<Gd<GpuParticles3D>>,
#[export]
cooldown: f64,
@ -144,6 +145,13 @@ pub struct Shotgun {
base: Base<Node3D>,
}
#[godot_api]
impl INode3D for Shotgun {
fn process(&mut self, delta: f64) {
self.cooldown_remaining -= delta;
}
}
#[godot_dyn]
impl Weapon for Shotgun {
fn shoot(
@ -155,7 +163,17 @@ impl Weapon for Shotgun {
up: Vector3,
deal_damage: bool,
) -> bool {
// TODO do effects
if self.cooldown_remaining > 0. {
return false;
}
if let Some(audio) = &mut self.sound_emitter {
audio.play();
}
if let Some(vfx) = &mut self.vfx {
vfx.set_emitting(true);
}
let mut colliders = HashSet::new();
for result in shotgun_ray(
@ -193,6 +211,8 @@ impl Weapon for Shotgun {
}
}
self.cooldown_remaining = self.cooldown;
true
}