generated from krampus/template-godot4
Added ball sfx
This commit is contained in:
parent
074dbb06dc
commit
cbed315048
|
@ -86,3 +86,19 @@ Asset credits
|
|||
*** Author: lmbubec
|
||||
|
||||
*** License: CC0
|
||||
|
||||
** grass1.wav - grass5.wav
|
||||
|
||||
*** Retrieved from https://freesound.org/people/mmmtoop/sounds/674030/
|
||||
|
||||
*** Author: mmmtoop
|
||||
|
||||
*** License: CC0
|
||||
|
||||
** sand1.wav - sand3.wav
|
||||
|
||||
*** Retrieved from https://freesound.org/people/Elements-Library/sounds/683785/
|
||||
|
||||
*** Author: Elements-Library
|
||||
|
||||
*** License: CC0
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
asset_dev/audio/674030__mmmtoop__230104-037_normalized_floor_mat_golf_ball_potential_kick_hit.wav (Stored with Git LFS)
Normal file
BIN
asset_dev/audio/674030__mmmtoop__230104-037_normalized_floor_mat_golf_ball_potential_kick_hit.wav (Stored with Git LFS)
Normal file
Binary file not shown.
BIN
asset_dev/audio/683785__elements-library__hard-impact-on-sand.wav (Stored with Git LFS)
Normal file
BIN
asset_dev/audio/683785__elements-library__hard-impact-on-sand.wav (Stored with Git LFS)
Normal file
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bp2iaowkqvtj8"
|
||||
path="res://.godot/imported/concrete1.wav-fd53edddc2b6023804ce5ffb1713f99a.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/concrete1.wav"
|
||||
dest_files=["res://.godot/imported/concrete1.wav-fd53edddc2b6023804ce5ffb1713f99a.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://4355dy0meqbm"
|
||||
path="res://.godot/imported/concrete2.wav-ca6360ffedc83e3ef200990602e8177f.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/concrete2.wav"
|
||||
dest_files=["res://.godot/imported/concrete2.wav-ca6360ffedc83e3ef200990602e8177f.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://orisjdcj3mes"
|
||||
path="res://.godot/imported/concrete3.wav-fd28bbeb346240f5e96bc491f8e0a16f.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/concrete3.wav"
|
||||
dest_files=["res://.godot/imported/concrete3.wav-fd28bbeb346240f5e96bc491f8e0a16f.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://o4whyv43rr1u"
|
||||
path="res://.godot/imported/concrete4.wav-4a18f12d2767719d7c6842841fd8d85b.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/concrete4.wav"
|
||||
dest_files=["res://.godot/imported/concrete4.wav-4a18f12d2767719d7c6842841fd8d85b.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://3csnnhxndt67"
|
||||
path="res://.godot/imported/concrete5.wav-bfae0b04558dbd1d5e4feefb4d59d6b9.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/concrete5.wav"
|
||||
dest_files=["res://.godot/imported/concrete5.wav-bfae0b04558dbd1d5e4feefb4d59d6b9.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://duayjxkje12ey"
|
||||
path="res://.godot/imported/concrete6.wav-ba9216b4a836ae83a36866e8d77787dc.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/concrete6.wav"
|
||||
dest_files=["res://.godot/imported/concrete6.wav-ba9216b4a836ae83a36866e8d77787dc.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bhhts1tkvv236"
|
||||
path="res://.godot/imported/concrete7.wav-053d67f927d1311d4f9640a798e1807e.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/concrete7.wav"
|
||||
dest_files=["res://.godot/imported/concrete7.wav-053d67f927d1311d4f9640a798e1807e.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://cwpyh41qbh8js"
|
||||
path="res://.godot/imported/grass1.wav-b4216b08493666f75784d0642045864f.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/grass1.wav"
|
||||
dest_files=["res://.godot/imported/grass1.wav-b4216b08493666f75784d0642045864f.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://cayyndwmxua5x"
|
||||
path="res://.godot/imported/grass2.wav-430d8da851839bd8347aa77dc113d7ff.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/grass2.wav"
|
||||
dest_files=["res://.godot/imported/grass2.wav-430d8da851839bd8347aa77dc113d7ff.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://b87bneqvovibi"
|
||||
path="res://.godot/imported/grass3.wav-1d9817728f47ac5124105d7c1f50eeb0.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/grass3.wav"
|
||||
dest_files=["res://.godot/imported/grass3.wav-1d9817728f47ac5124105d7c1f50eeb0.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://b0fup7btd0b1k"
|
||||
path="res://.godot/imported/grass4.wav-29729dac6e9ca8db822b77925ab1a78e.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/grass4.wav"
|
||||
dest_files=["res://.godot/imported/grass4.wav-29729dac6e9ca8db822b77925ab1a78e.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://c6d1rse1aveiy"
|
||||
path="res://.godot/imported/grass5.wav-c1b5dcb7a89369922bcbafb0da9e769f.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/grass5.wav"
|
||||
dest_files=["res://.godot/imported/grass5.wav-c1b5dcb7a89369922bcbafb0da9e769f.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bbbp6wrkuhkek"
|
||||
path="res://.godot/imported/sand1.wav-adf26d7ca3003a8860fb46cc0758e7bd.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/sand1.wav"
|
||||
dest_files=["res://.godot/imported/sand1.wav-adf26d7ca3003a8860fb46cc0758e7bd.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://b5xx5t050i4p"
|
||||
path="res://.godot/imported/sand2.wav-8556fd9b18e6810c91fc69b1f24a839b.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/sand2.wav"
|
||||
dest_files=["res://.godot/imported/sand2.wav-8556fd9b18e6810c91fc69b1f24a839b.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://c35jy105xr640"
|
||||
path="res://.godot/imported/sand3.wav-708a3206418fb40e4b4f401186c037b1.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sound/sfx/ball/sand3.wav"
|
||||
dest_files=["res://.godot/imported/sand3.wav-708a3206418fb40e4b4f401186c037b1.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
|
@ -1,17 +1,10 @@
|
|||
[gd_scene load_steps=51 format=3 uid="uid://bm2o3mex10v11"]
|
||||
[gd_scene load_steps=37 format=3 uid="uid://bm2o3mex10v11"]
|
||||
|
||||
[ext_resource type="Texture2D" path="res://assets/textures/grass_fairway/grass_fairway_albedo.dds" id="2_e4m27"]
|
||||
[ext_resource type="Texture2D" path="res://assets/textures/grass_rough/grass_rough_albedo.dds" id="4_p0awb"]
|
||||
[ext_resource type="Texture2D" path="res://assets/textures/grass_rough/grass_rough_normal.dds" id="4_yhjhv"]
|
||||
[ext_resource type="Texture2D" path="res://assets/textures/grass_fairway/grass_fairway_normal.dds" id="5_o361t"]
|
||||
[ext_resource type="Terrain3DAssets" uid="uid://cwl34gstabgrx" path="res://levels/debug_level/terrain_assets.res" id="1_5smdk"]
|
||||
[ext_resource type="Shader" path="res://src/shaders/psx_water.gdshader" id="6_0efu4"]
|
||||
[ext_resource type="Texture2D" uid="uid://c47ern0l2d50r" path="res://assets/vista_2.png" id="6_ectru"]
|
||||
[ext_resource type="Texture2D" path="res://assets/textures/sand_trap/sand_trap_albedo.dds" id="6_nlea7"]
|
||||
[ext_resource type="Texture2D" path="res://assets/textures/sand_trap/sand_trap_normal.dds" id="7_f25dn"]
|
||||
[ext_resource type="Texture2D" uid="uid://con5a36t6n6sq" path="res://assets/textures/clear_sea_water_2048x2048.png" id="7_t86h2"]
|
||||
[ext_resource type="Texture2D" path="res://assets/textures/mountain_rock/mountain_rock_albedo.dds" id="8_ujbjy"]
|
||||
[ext_resource type="Script" path="res://src/world/ball_zone/ball_zone.gd" id="9_jwlau"]
|
||||
[ext_resource type="Texture2D" path="res://assets/textures/mountain_rock/mountain_rock_normal.dds" id="9_rrguh"]
|
||||
[ext_resource type="PackedScene" uid="uid://dagh38vap4t1d" path="res://src/props/scenery/city/concrete_building_1.tscn" id="10_lf15j"]
|
||||
[ext_resource type="PackedScene" uid="uid://cjubxs7peir5k" path="res://src/props/scenery/city/kana_signboard.tscn" id="11_evxup"]
|
||||
[ext_resource type="PackedScene" uid="uid://di7aql54lksn7" path="res://src/props/scenery/trees/palm_tree/palm_tree.tscn" id="12_sswxf"]
|
||||
|
@ -61,53 +54,6 @@ world_background = 2
|
|||
texture_filtering = 1
|
||||
auto_shader = true
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_l1sla"]
|
||||
transparency = 4
|
||||
cull_mode = 2
|
||||
vertex_color_use_as_albedo = true
|
||||
backlight_enabled = true
|
||||
backlight = Color(0.5, 0.5, 0.5, 1)
|
||||
distance_fade_mode = 1
|
||||
distance_fade_min_distance = 960.0
|
||||
distance_fade_max_distance = 480.0
|
||||
|
||||
[sub_resource type="Terrain3DMeshAsset" id="Terrain3DMeshAsset_iaq2t"]
|
||||
height_offset = 0.5
|
||||
density = 10.0
|
||||
material_override = SubResource("StandardMaterial3D_l1sla")
|
||||
generated_type = 1
|
||||
|
||||
[sub_resource type="Terrain3DTextureAsset" id="Terrain3DTextureAsset_kocfk"]
|
||||
name = "Rough Grass"
|
||||
albedo_texture = ExtResource("4_p0awb")
|
||||
normal_texture = ExtResource("4_yhjhv")
|
||||
uv_scale = 0.01
|
||||
|
||||
[sub_resource type="Terrain3DTextureAsset" id="Terrain3DTextureAsset_vmhlw"]
|
||||
name = "Fairway Grass"
|
||||
id = 1
|
||||
albedo_texture = ExtResource("2_e4m27")
|
||||
normal_texture = ExtResource("5_o361t")
|
||||
uv_scale = 0.01
|
||||
|
||||
[sub_resource type="Terrain3DTextureAsset" id="Terrain3DTextureAsset_k6h8c"]
|
||||
name = "sand_trap_albedo"
|
||||
id = 2
|
||||
albedo_texture = ExtResource("6_nlea7")
|
||||
normal_texture = ExtResource("7_f25dn")
|
||||
uv_scale = 0.01
|
||||
|
||||
[sub_resource type="Terrain3DTextureAsset" id="Terrain3DTextureAsset_13d2a"]
|
||||
name = "mountain_rock_albedo"
|
||||
id = 3
|
||||
albedo_texture = ExtResource("8_ujbjy")
|
||||
normal_texture = ExtResource("9_rrguh")
|
||||
uv_scale = 0.02
|
||||
|
||||
[sub_resource type="Terrain3DAssets" id="Terrain3DAssets_eq5uw"]
|
||||
mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_iaq2t")])
|
||||
texture_list = Array[Terrain3DTextureAsset]([SubResource("Terrain3DTextureAsset_kocfk"), SubResource("Terrain3DTextureAsset_vmhlw"), SubResource("Terrain3DTextureAsset_k6h8c"), SubResource("Terrain3DTextureAsset_13d2a")])
|
||||
|
||||
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_h8tes"]
|
||||
panorama = ExtResource("6_ectru")
|
||||
|
||||
|
@ -243,7 +189,7 @@ point_count = 5
|
|||
[node name="Terrain3D" type="Terrain3D" parent="."]
|
||||
data_directory = "res://levels/debug_level/terrain_3d_data"
|
||||
material = SubResource("Terrain3DMaterial_woy2k")
|
||||
assets = SubResource("Terrain3DAssets_eq5uw")
|
||||
assets = ExtResource("1_5smdk")
|
||||
mesh_size = 64
|
||||
top_level = true
|
||||
metadata/_edit_lock_ = true
|
||||
|
@ -260,6 +206,8 @@ shadow_blur = 4.0
|
|||
[node name="Course" type="Node3D" parent="."]
|
||||
|
||||
[node name="Fairway" type="Area3D" parent="Course"]
|
||||
gravity_point_center = Vector3(0, 1, 0)
|
||||
gravity_direction = Vector3(0, 1, 0)
|
||||
script = ExtResource("9_jwlau")
|
||||
terrain_angular_damping = 2.0
|
||||
|
||||
|
|
Binary file not shown.
|
@ -197,6 +197,7 @@ ball_previous={
|
|||
|
||||
3d_physics/layer_1="Collision Geometry"
|
||||
3d_physics/layer_2="Layer 3"
|
||||
3d_physics/layer_32="Grass Audio"
|
||||
|
||||
[physics]
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
class_name BallSFX extends Node3D
|
||||
## Controller for ball sound effects.
|
||||
|
||||
const BASE_VOLUME := -36.0
|
||||
const MAX_VOLUME := 3.0
|
||||
const VELOCITY_ATTENUATION_SCALE := 400.0
|
||||
|
||||
const GRASS_PHYSICAL_LAYER := 1 << 32
|
||||
const SAND_PHYSICAL_LAYER := 1 << 31
|
||||
|
||||
@onready var parent: GameBall = $".."
|
||||
|
||||
@onready var grass_sfx_player: AudioStreamPlayer3D = %GrassSFXPlayer
|
||||
@onready var concrete_sfx_player: AudioStreamPlayer3D = %ConcreteSFXPlayer
|
||||
@onready var sand_sfx_player: AudioStreamPlayer3D = %SandSFXPlayer
|
||||
|
||||
|
||||
func _force_attenuated_volume() -> float:
|
||||
# Attenuate volume based on impact force
|
||||
return lerpf(
|
||||
BASE_VOLUME,
|
||||
MAX_VOLUME,
|
||||
clampf(parent.linear_velocity.length_squared() / VELOCITY_ATTENUATION_SCALE, 0, 1)
|
||||
)
|
||||
|
||||
|
||||
func _play_sfx(player: AudioStreamPlayer3D) -> void:
|
||||
player.volume_db = _force_attenuated_volume()
|
||||
print("PLAYING: ", player, "... VOLUME: ", player.volume_db)
|
||||
player.play()
|
||||
|
||||
|
||||
func play_terrain_sfx(tex_id: int) -> void:
|
||||
var player := grass_sfx_player
|
||||
match tex_id:
|
||||
2: # sand
|
||||
player = sand_sfx_player
|
||||
3: # rock
|
||||
player = concrete_sfx_player
|
||||
|
||||
_play_sfx(player)
|
||||
|
||||
|
||||
## Select the appropriate SFX to play based on the collision layer of the collider.
|
||||
##
|
||||
## We use the upper bits of the collision layer to indicate standard SFX.
|
||||
func play_physical_sfx(collision_mask: int) -> void:
|
||||
var player := concrete_sfx_player
|
||||
if collision_mask & GRASS_PHYSICAL_LAYER:
|
||||
player = grass_sfx_player
|
||||
elif collision_mask & SAND_PHYSICAL_LAYER:
|
||||
player = sand_sfx_player
|
||||
_play_sfx(player)
|
|
@ -52,6 +52,8 @@ var _position_on_last_wake: Vector3
|
|||
var _awake := false
|
||||
var _zones: Array[BallZone] = []
|
||||
|
||||
@onready var sfx: BallSFX = %SFX
|
||||
|
||||
@onready var normal_physics: PhysicsMaterial = preload(
|
||||
"res://src/equipment/balls/physics_ball/normal_physics.tres"
|
||||
)
|
||||
|
@ -142,3 +144,21 @@ func _on_sleeping_state_changed() -> void:
|
|||
if sleeping:
|
||||
# Trigger to reassign on wake
|
||||
_awake = false
|
||||
|
||||
|
||||
func _on_collision(body: Node) -> void:
|
||||
if body is Terrain3D:
|
||||
var texture_blend: Vector3 = (body as Terrain3D).data.get_texture_id(global_position)
|
||||
print("T3D texture blend: ", texture_blend)
|
||||
# TODO maybe blend audio?
|
||||
|
||||
# Figure out audio for autoshader
|
||||
var tex_id: float = 0 if texture_blend.x == 3 and texture_blend.z == 0 else texture_blend.x
|
||||
|
||||
sfx.play_terrain_sfx(tex_id)
|
||||
elif body is CSGShape3D:
|
||||
sfx.play_physical_sfx((body as CSGShape3D).collision_layer)
|
||||
elif body is CollisionObject3D:
|
||||
sfx.play_physical_sfx((body as CollisionObject3D).collision_layer)
|
||||
else:
|
||||
print_debug("COLLIDER: ", body)
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://dfttci386ohip"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://dfttci386ohip"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/equipment/balls/physics_ball/game_ball.gd" id="1_iwh2u"]
|
||||
[ext_resource type="PhysicsMaterial" uid="uid://3bih72l068ic" path="res://src/equipment/balls/physics_ball/normal_physics.tres" id="1_l23pw"]
|
||||
[ext_resource type="Texture2D" uid="uid://ckhiq6rfjv63u" path="res://assets/textures/gfolfball/gfolfball.png" id="1_y3q5j"]
|
||||
[ext_resource type="Texture2D" uid="uid://btntjs7mbdigu" path="res://assets/textures/gfolfball/gfolfball_normal.png" id="2_mx7l6"]
|
||||
[ext_resource type="Script" path="res://src/equipment/balls/physics_ball/ball_sfx.gd" id="5_bhshl"]
|
||||
[ext_resource type="AudioStream" uid="uid://cayyndwmxua5x" path="res://assets/sound/sfx/ball/grass2.wav" id="7_l22cv"]
|
||||
[ext_resource type="AudioStream" uid="uid://orisjdcj3mes" path="res://assets/sound/sfx/ball/concrete3.wav" id="7_t2ak2"]
|
||||
[ext_resource type="AudioStream" uid="uid://o4whyv43rr1u" path="res://assets/sound/sfx/ball/concrete4.wav" id="8_0anjl"]
|
||||
[ext_resource type="AudioStream" uid="uid://3csnnhxndt67" path="res://assets/sound/sfx/ball/concrete5.wav" id="9_p0lmw"]
|
||||
[ext_resource type="AudioStream" uid="uid://bbbp6wrkuhkek" path="res://assets/sound/sfx/ball/sand1.wav" id="10_b64mx"]
|
||||
[ext_resource type="AudioStream" uid="uid://b5xx5t050i4p" path="res://assets/sound/sfx/ball/sand2.wav" id="11_ed8je"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_xqofq"]
|
||||
albedo_texture = ExtResource("1_y3q5j")
|
||||
|
@ -66,6 +73,25 @@ func _draw() -> void:
|
|||
draw_line(start, end, COLOR_MAGNUS, WIDTH)
|
||||
"
|
||||
|
||||
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_gc38m"]
|
||||
playback_mode = 1
|
||||
random_pitch = 1.1
|
||||
streams_count = 1
|
||||
stream_0/stream = ExtResource("7_l22cv")
|
||||
|
||||
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_tg0n0"]
|
||||
random_pitch = 1.1
|
||||
streams_count = 3
|
||||
stream_0/stream = ExtResource("7_t2ak2")
|
||||
stream_1/stream = ExtResource("8_0anjl")
|
||||
stream_2/stream = ExtResource("9_p0lmw")
|
||||
|
||||
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_uu1f8"]
|
||||
playback_mode = 1
|
||||
streams_count = 2
|
||||
stream_0/stream = ExtResource("10_b64mx")
|
||||
stream_1/stream = ExtResource("11_ed8je")
|
||||
|
||||
[node name="PhysicsBall" type="RigidBody3D"]
|
||||
mass = 0.05
|
||||
physics_material_override = ExtResource("1_l23pw")
|
||||
|
@ -97,4 +123,28 @@ grow_vertical = 2
|
|||
script = SubResource("GDScript_p4v7o")
|
||||
draw_reoriented_basis = false
|
||||
|
||||
[node name="SFX" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("5_bhshl")
|
||||
|
||||
[node name="GrassSFXPlayer" type="AudioStreamPlayer3D" parent="SFX"]
|
||||
unique_name_in_owner = true
|
||||
stream = SubResource("AudioStreamRandomizer_gc38m")
|
||||
unit_size = 40.0
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="ConcreteSFXPlayer" type="AudioStreamPlayer3D" parent="SFX"]
|
||||
unique_name_in_owner = true
|
||||
stream = SubResource("AudioStreamRandomizer_tg0n0")
|
||||
unit_size = 40.0
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="SandSFXPlayer" type="AudioStreamPlayer3D" parent="SFX"]
|
||||
unique_name_in_owner = true
|
||||
stream = SubResource("AudioStreamRandomizer_uu1f8")
|
||||
unit_size = 40.0
|
||||
max_db = 0.0
|
||||
bus = &"SFX"
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_collision"]
|
||||
[connection signal="sleeping_state_changed" from="." to="." method="_on_sleeping_state_changed"]
|
||||
|
|
|
@ -247,13 +247,14 @@ func take_shot() -> void:
|
|||
# Impact screenshake & hitlag
|
||||
if game:
|
||||
if shot_power > BIG_POWER_THRESHOLD:
|
||||
game.viewport.hit_lag_big()
|
||||
#game.viewport.hit_lag_big()
|
||||
var shake_intensity: float = (
|
||||
10.0 * (shot_power - BIG_POWER_THRESHOLD) / (1.0 - BIG_POWER_THRESHOLD)
|
||||
)
|
||||
game.viewport.screen_shake(shake_intensity, 1.0)
|
||||
else:
|
||||
game.viewport.hit_lag_small()
|
||||
pass
|
||||
#game.viewport.hit_lag_small()
|
||||
|
||||
print_debug("WHACK!\nPower: ", shot_power, "\nCurve: ", shot_curve)
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ bones/10/scale = Vector3(1, 1, 1)
|
|||
bones/11/rotation = Quaternion(-0.13894, 0.0183908, 0.000355869, 0.99013)
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." index="2"]
|
||||
collision_layer = 2147483649
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D" index="0"]
|
||||
shape = SubResource("ConcavePolygonShape3D_bp5t6")
|
||||
|
|
Loading…
Reference in New Issue