Added collision sound effect

This commit is contained in:
alex-kumpula 2023-11-12 16:42:00 -07:00
parent 63f3bdec03
commit adfdc67544
4 changed files with 107 additions and 46 deletions

30
godot/CollisionSound.cs Normal file
View File

@ -0,0 +1,30 @@
using Godot;
using System;
public partial class CollisionSound : AudioStreamPlayer
{
Node controller;
bool firstPlayed = false;
public override void _Ready()
{
controller = GetNode<Node>("/root/ControllerEventBus");
Callable callable = new Callable(this, MethodName.OnControllerContact);
controller.Connect("new_target", callable);
this.OnControllerContact(this);
}
public void OnControllerContact(Node node)
{
if (firstPlayed) this.Play();
firstPlayed = true;
}
}

BIN
godot/audio/impact.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://d2ncd2qoklbbe"
path="res://.godot/imported/impact.wav-606f8b40b78eec03bfd2693747f9e1cb.sample"
[deps]
source_file="res://audio/impact.wav"
dest_files=["res://.godot/imported/impact.wav-606f8b40b78eec03bfd2693747f9e1cb.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

View File

@ -1,8 +1,10 @@
[gd_scene load_steps=20 format=3 uid="uid://pcj1nku3mf21"]
[gd_scene load_steps=22 format=3 uid="uid://pcj1nku3mf21"]
[ext_resource type="PackedScene" uid="uid://bua7f25rpewkp" path="res://small_room.glb" id="1_mxs07"]
[ext_resource type="PackedScene" uid="uid://drmb4sitb74fx" path="res://control_scheme/controller.tscn" id="2_4ciir"]
[ext_resource type="AudioStream" uid="uid://d2ncd2qoklbbe" path="res://audio/impact.wav" id="2_rmoch"]
[ext_resource type="PackedScene" uid="uid://c43pr474qofhl" path="res://physics/grape.tscn" id="3_cknru"]
[ext_resource type="Script" path="res://CollisionSound.cs" id="3_wyrva"]
[ext_resource type="PackedScene" path="res://cake.tscn" id="4_pqssx"]
[ext_resource type="PackedScene" uid="uid://cfpiau12q3fut" path="res://Objects/child/child.tscn" id="5_o3qks"]
[ext_resource type="PackedScene" uid="uid://dfkyytk42ecwk" path="res://Objects/igloo/igloo.tscn" id="6_g4v1s"]
@ -45,37 +47,42 @@ size = Vector3(2.00501, 0.0572979, 2.00633)
[node name="small_room" instance=ExtResource("1_mxs07")]
[node name="Collision Sound" type="AudioStreamPlayer" parent="." index="0"]
stream = ExtResource("2_rmoch")
volume_db = -21.345
script = ExtResource("3_wyrva")
[node name="StaticBody3D" parent="room" index="0"]
visible = false
[node name="controller" parent="." index="2" node_paths=PackedStringArray("camera", "initial_target") instance=ExtResource("2_4ciir")]
[node name="controller" parent="." index="3" node_paths=PackedStringArray("camera", "initial_target") instance=ExtResource("2_4ciir")]
camera = NodePath("../Camera3D")
initial_target = NodePath("../grape")
[node name="grape" parent="." index="3" instance=ExtResource("3_cknru")]
[node name="grape" parent="." index="4" instance=ExtResource("3_cknru")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.475577, 1.56762, -0.647942)
physics_material_override = SubResource("PhysicsMaterial_lwj18")
[node name="grape2" parent="." index="4" instance=ExtResource("3_cknru")]
[node name="grape2" parent="." index="5" instance=ExtResource("3_cknru")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.385778, 1.56762, 0.220826)
physics_material_override = SubResource("PhysicsMaterial_lwj18")
[node name="grape3" parent="." index="5" instance=ExtResource("3_cknru")]
[node name="grape3" parent="." index="6" instance=ExtResource("3_cknru")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.272993, 1.56762, 0.104417)
physics_material_override = SubResource("PhysicsMaterial_lwj18")
[node name="Camera3D" type="Camera3D" parent="." index="6"]
[node name="Camera3D" type="Camera3D" parent="." index="7"]
current = true
[node name="cake" parent="." index="7" instance=ExtResource("4_pqssx")]
[node name="cake" parent="." index="8" instance=ExtResource("4_pqssx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.45077, 0)
[node name="child" parent="." index="8" instance=ExtResource("5_o3qks")]
[node name="child" parent="." index="9" instance=ExtResource("5_o3qks")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.46064)
[node name="igloo" parent="." index="9" instance=ExtResource("6_g4v1s")]
[node name="igloo" parent="." index="10" instance=ExtResource("6_g4v1s")]
[node name="screen_shader" type="Control" parent="." index="10"]
[node name="screen_shader" type="Control" parent="." index="11"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@ -101,129 +108,129 @@ environment = SubResource("Environment_nytpg")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="screen_shader" index="2"]
transform = Transform3D(0.495368, 0.868683, -1.47631e-08, -0.635304, 0.362283, 0.682011, 0.592452, -0.337846, 0.731342, 0, 2.28, 1.03672)
[node name="TAS UI" parent="." index="11" instance=ExtResource("9_2xkrk")]
[node name="TAS UI" parent="." index="12" instance=ExtResource("9_2xkrk")]
[node name="Music Player" type="AudioStreamPlayer" parent="." index="12"]
[node name="Music Player" type="AudioStreamPlayer" parent="." index="13"]
stream = ExtResource("10_c38y3")
volume_db = -34.667
autoplay = true
[node name="balloon" parent="." index="13" instance=ExtResource("12_2uywm")]
[node name="balloon" parent="." index="14" instance=ExtResource("12_2uywm")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 0)
[node name="balloon2" parent="." index="14" instance=ExtResource("12_2uywm")]
[node name="balloon2" parent="." index="15" instance=ExtResource("12_2uywm")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 2, 1)
[node name="balloon4" parent="." index="15" instance=ExtResource("12_2uywm")]
[node name="balloon4" parent="." index="16" instance=ExtResource("12_2uywm")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.979048, 2.03566, -1.15501)
[node name="balloon3" parent="." index="16" instance=ExtResource("12_2uywm")]
[node name="balloon3" parent="." index="17" instance=ExtResource("12_2uywm")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 2)
[node name="Domino" parent="." index="17" instance=ExtResource("11_4wk46")]
[node name="Domino" parent="." index="18" instance=ExtResource("11_4wk46")]
transform = Transform3D(1, 0, 0, 0, 0.912134, -0.409891, 0, 0.409891, 0.912134, 0.874793, 1.62482, -0.72137)
[node name="Domino3" parent="." index="18" instance=ExtResource("11_4wk46")]
[node name="Domino3" parent="." index="19" instance=ExtResource("11_4wk46")]
transform = Transform3D(1, 0, 0, 0, 0.894092, -0.447884, 0, 0.447884, 0.894092, 0.874793, 1.52746, -0.604334)
[node name="Domino4" parent="." index="19" instance=ExtResource("11_4wk46")]
[node name="Domino4" parent="." index="20" instance=ExtResource("11_4wk46")]
transform = Transform3D(1, 0, 0, 0, 0.832051, -0.554699, 0, 0.554699, 0.832051, 0.874793, 1.49062, -0.472212)
[node name="Domino5" parent="." index="20" instance=ExtResource("11_4wk46")]
[node name="Domino5" parent="." index="21" instance=ExtResource("11_4wk46")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.874793, 1.49062, -0.348998)
[node name="Domino7" parent="." index="21" instance=ExtResource("11_4wk46")]
[node name="Domino7" parent="." index="22" instance=ExtResource("11_4wk46")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.874793, 1.49062, -0.225395)
mass = 1.0
[node name="Domino8" parent="." index="22" instance=ExtResource("11_4wk46")]
[node name="Domino8" parent="." index="23" instance=ExtResource("11_4wk46")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.874793, 1.49062, -0.074692)
mass = 1.0
[node name="Domino9" parent="." index="23" instance=ExtResource("11_4wk46")]
[node name="Domino9" parent="." index="24" instance=ExtResource("11_4wk46")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.874793, 1.49062, 0.0335652)
mass = 1.0
[node name="Domino12" parent="." index="24" instance=ExtResource("11_4wk46")]
[node name="Domino12" parent="." index="25" instance=ExtResource("11_4wk46")]
transform = Transform3D(0.869081, 0, -0.49467, 0, 1, 0, 0.49467, 0, 0.869081, 0.859882, 1.49062, 0.204117)
mass = 1.0
[node name="Domino18" parent="." index="25" instance=ExtResource("11_4wk46")]
[node name="Domino18" parent="." index="26" instance=ExtResource("11_4wk46")]
transform = Transform3D(0.869081, 0, -0.49467, 0, 1, 0, 0.49467, 0, 0.869081, 0.791925, 1.49062, 0.34855)
mass = 1.0
[node name="Domino13" parent="." index="26" instance=ExtResource("11_4wk46")]
[node name="Domino13" parent="." index="27" instance=ExtResource("11_4wk46")]
transform = Transform3D(0.843804, 0, -0.536652, 0, 1, 0, 0.536652, 0, 0.843804, 0.704577, 1.49062, 0.482536)
mass = 1.0
[node name="Domino15" parent="." index="27" instance=ExtResource("11_4wk46")]
[node name="Domino15" parent="." index="28" instance=ExtResource("11_4wk46")]
transform = Transform3D(0.843804, 0, -0.536652, 0, 1, 0, 0.536652, 0, 0.843804, 0.611049, 1.49062, 0.639537)
mass = 1.0
[node name="Domino16" parent="." index="28" instance=ExtResource("11_4wk46")]
[node name="Domino16" parent="." index="29" instance=ExtResource("11_4wk46")]
transform = Transform3D(0.521218, 0, -0.853423, 0, 1, 0, 0.853423, 0, 0.521218, 0.468388, 1.49062, 0.782435)
mass = 1.0
[node name="Domino17" parent="." index="29" instance=ExtResource("11_4wk46")]
[node name="Domino17" parent="." index="30" instance=ExtResource("11_4wk46")]
transform = Transform3D(0.25315, 0, -0.967427, 0, 1, 0, 0.967427, 0, 0.25315, 0.308225, 1.49062, 0.872444)
mass = 1.0
[node name="Domino20" parent="." index="30" instance=ExtResource("11_4wk46")]
[node name="Domino20" parent="." index="31" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.0732207, 0, -0.997316, 0, 1, 0, 0.997316, 0, -0.0732207, 0.123492, 1.49062, 0.890783)
mass = 1.0
[node name="Domino21" parent="." index="31" instance=ExtResource("11_4wk46")]
[node name="Domino21" parent="." index="32" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.0732207, 0, -0.997316, 0, 1, 0, 0.997316, 0, -0.0732207, -0.0613621, 1.49062, 0.889423)
mass = 1.0
[node name="Domino22" parent="." index="32" instance=ExtResource("11_4wk46")]
[node name="Domino22" parent="." index="33" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.0732207, 0, -0.997316, 0, 1, 0, 0.997316, 0, -0.0732207, -0.255018, 1.49062, 0.885057)
mass = 1.0
[node name="Domino23" parent="." index="33" instance=ExtResource("11_4wk46")]
[node name="Domino23" parent="." index="34" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.0732207, 0, -0.997316, 0, 1, 0, 0.997316, 0, -0.0732207, -0.438459, 1.49062, 0.873156)
mass = 1.0
[node name="Domino24" parent="." index="34" instance=ExtResource("11_4wk46")]
[node name="Domino24" parent="." index="35" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.637599, 0, -0.770369, 0, 1, 0, 0.770369, 0, -0.637599, -0.624725, 1.49062, 0.8124)
mass = 1.0
[node name="Domino25" parent="." index="35" instance=ExtResource("11_4wk46")]
[node name="Domino25" parent="." index="36" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.736959, 0, -0.675938, 0, 1, 0, 0.675938, 0, -0.736959, -0.770258, 1.49062, 0.690065)
mass = 1.0
[node name="Domino26" parent="." index="36" instance=ExtResource("11_4wk46")]
[node name="Domino26" parent="." index="37" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.877791, 0, -0.479044, 0, 1, 0, 0.479044, 0, -0.877791, -0.874925, 1.49062, 0.549677)
mass = 1.0
[node name="Domino27" parent="." index="37" instance=ExtResource("11_4wk46")]
[node name="Domino27" parent="." index="38" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.984774, 0, -0.173837, 0, 1, 0, 0.173837, 0, -0.984774, -0.901783, 1.49062, 0.370477)
mass = 1.0
[node name="Domino28" parent="." index="38" instance=ExtResource("11_4wk46")]
[node name="Domino28" parent="." index="39" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.984774, 0, -0.173837, 0, 1, 0, 0.173837, 0, -0.984774, -0.914746, 1.49062, 0.19037)
mass = 1.0
[node name="Domino29" parent="." index="39" instance=ExtResource("11_4wk46")]
[node name="Domino29" parent="." index="40" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.999834, 0, 0.0182376, 0, 1, 0, -0.0182376, 0, -0.999834, -0.902489, 1.49062, -0.0236639)
mass = 1.0
[node name="Domino30" parent="." index="40" instance=ExtResource("11_4wk46")]
[node name="Domino30" parent="." index="41" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.999834, 0, 0.0182376, 0, 1, 0, -0.0182376, 0, -0.999834, -0.902489, 1.49062, -0.220417)
mass = 1.0
[node name="Domino31" parent="." index="41" instance=ExtResource("11_4wk46")]
[node name="Domino31" parent="." index="42" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.999834, 0, 0.0182376, 0, 1, 0, -0.0182376, 0, -0.999834, -0.902489, 1.49062, -0.413874)
mass = 1.0
[node name="Domino32" parent="." index="42" instance=ExtResource("11_4wk46")]
[node name="Domino32" parent="." index="43" instance=ExtResource("11_4wk46")]
transform = Transform3D(-0.999834, 0, 0.0182376, 0, 1, 0, -0.0182376, 0, -0.999834, -0.903498, 1.49062, -0.634788)
mass = 1.0
[node name="Domino2" parent="." index="43" instance=ExtResource("11_4wk46")]
[node name="Domino2" parent="." index="44" instance=ExtResource("11_4wk46")]
transform = Transform3D(1, 0, 0, 0, 0.770947, -0.636899, 0, 0.636899, 0.770947, 0.861071, 1.7376, -0.788087)
[node name="Table Collision" type="RigidBody3D" parent="." index="44"]
[node name="Table Collision" type="RigidBody3D" parent="." index="45"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.32475, 0)
lock_rotation = true
freeze = true
@ -232,11 +239,11 @@ freeze = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.00472426, 0)
shape = SubResource("BoxShape3D_vb47w")
[node name="Area3D" type="Area3D" parent="." index="45"]
[node name="Area3D" type="Area3D" parent="." index="46"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.32475, 0)
visible = false
[node name="present" parent="." index="46" instance=ExtResource("13_1uqwi")]
[node name="present" parent="." index="47" instance=ExtResource("13_1uqwi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.867866, 1.56404, -1.01166)
mass = 0.01
power_max = 20.0