Add impact sound to chain window

This commit is contained in:
Jens Pitkänen 2020-08-10 20:35:54 +03:00
parent 5964d9432e
commit a2e57c2988
12 changed files with 290 additions and 23 deletions

View File

@ -1,5 +1,24 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!243 &-8030293084440089681
AudioMixerGroupController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: EnvHits
m_AudioMixer: {fileID: 24100000}
m_GroupID: f58915c82845f9b47a322aeefeaf0116
m_Children: []
m_Volume: 8bee47ecf1719a34c9a4509adc3d7f50
m_Pitch: 3d4dde8cdd48f044b9280d72a780b260
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: 4401202656874143845}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0
--- !u!244 &-3601797963847308308
AudioMixerEffectController:
m_ObjectHideFlags: 3
@ -55,6 +74,7 @@ AudioMixerController:
- a1145e9de5e1d9d4980fbfb98ac09640
- c95b70575255b7444a07837f795dda0c
- 3a0a85f42d9d34f45a8e1b38e73db35a
- f58915c82845f9b47a322aeefeaf0116
name: View
m_CurrentViewIndex: 0
m_TargetSnapshot: {fileID: 24500006}
@ -118,6 +138,20 @@ AudioMixerEffectController:
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!244 &4401202656874143845
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: 723bb9b90d69394469bde81e0fff9a9f
m_EffectName: Attenuation
m_MixLevel: 00c73b77a6f0a9d4584f2133fcbfa019
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!243 &6277318630853483794
AudioMixerGroupController:
m_ObjectHideFlags: 0
@ -163,6 +197,7 @@ AudioMixerGroupController:
m_Children:
- {fileID: -1410552352759146441}
- {fileID: 6277318630853483794}
- {fileID: -8030293084440089681}
m_Volume: 1a91e250aa8fec749b1861a5c8e7ff48
m_Pitch: c21e265de00bfe64eba2868212c34fa2
m_Send: 00000000000000000000000000000000

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 21a10f39053eed742bc40e3d3a79d3b0
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 730cd0a8b458ea549b2f23af563b7b36
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1714,6 +1714,9 @@ MonoBehaviour:
BulletHitLayer:
serializedVersion: 2
m_Bits: 823
BulletPassLayer:
serializedVersion: 2
m_Bits: 8192
Cooldown: 1
Lerpables:
- {fileID: 6585337033203946896}

View File

@ -151,7 +151,6 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1782355448}
- {fileID: 1901268757}
- {fileID: 315509112}
m_Father: {fileID: 0}
m_RootOrder: 7
@ -463,6 +462,10 @@ PrefabInstance:
propertyPath: m_Name
value: DeadScreen
objectReference: {fileID: 0}
- target: {fileID: 5471352474105955327, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5752193893751936224, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3}
propertyPath: Crosshair
value:
@ -558,6 +561,133 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3}
m_PrefabInstance: {fileID: 360197056}
m_PrefabAsset: {fileID: 0}
--- !u!1 &422830293
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 422830294}
- component: {fileID: 422830295}
m_Layer: 13
m_Name: Audio Source
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &422830294
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 422830293}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1782355448}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &422830295
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 422830293}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: -8030293084440089681, guid: ff7bf5284859d9f45a64971a67bb173a, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &529416811
GameObject:
m_ObjectHideFlags: 0
@ -1444,6 +1574,10 @@ PrefabInstance:
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 9081539380605237274, guid: e32cf25e03a88b04d929cd6fbf906421, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e32cf25e03a88b04d929cd6fbf906421, type: 3}
--- !u!224 &816236546 stripped
@ -2595,6 +2729,7 @@ GameObject:
- component: {fileID: 1782355451}
- component: {fileID: 1782355450}
- component: {fileID: 1782355449}
- component: {fileID: 1782355452}
m_Layer: 13
m_Name: WindowSideA
m_TagString: Untagged
@ -2612,7 +2747,9 @@ Transform:
m_LocalRotation: {x: -0, y: 1, z: -0, w: 0.0000029653306}
m_LocalPosition: {x: -28, y: 3, z: 0}
m_LocalScale: {x: 2, y: 2, z: 1}
m_Children: []
m_Children:
- {fileID: 1901268757}
- {fileID: 422830294}
m_Father: {fileID: 21404627}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
@ -2678,6 +2815,22 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1782355447}
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!114 &1782355452
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1782355447}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 03f421a8b121f76468bdf7a1961dcbda, type: 3}
m_Name:
m_EditorClassIdentifier:
Source: {fileID: 422830295}
Clips:
- {fileID: 8300000, guid: 21a10f39053eed742bc40e3d3a79d3b0, type: 3}
- {fileID: 8300000, guid: 730cd0a8b458ea549b2f23af563b7b36, type: 3}
--- !u!1 &1901268756
GameObject:
m_ObjectHideFlags: 0
@ -2689,7 +2842,6 @@ GameObject:
- component: {fileID: 1901268757}
- component: {fileID: 1901268760}
- component: {fileID: 1901268759}
- component: {fileID: 1901268758}
m_Layer: 13
m_Name: WindowSideB
m_TagString: Untagged
@ -2704,26 +2856,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1901268756}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -28, y: 3, z: 0}
m_LocalScale: {x: 2, y: 2, z: 1}
m_LocalRotation: {x: -0, y: -1, z: -0, w: 0.0000029653306}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 21404627}
m_RootOrder: 1
m_Father: {fileID: 1782355448}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &1901268758
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1901268756}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 6.1232336e-17}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &1901268759
MeshRenderer:
m_ObjectHideFlags: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c5a68b9cb00447b4081c62dbe2768b50
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NeonTea.Quakeball.Audio {
public class ImpactSound : MonoBehaviour {
public AudioSource Source;
public AudioClip[] Clips;
public void PlayAt(Vector3 position) {
transform.position = position;
Source.PlayOneShot(GetRandomClip());
}
private AudioClip GetRandomClip() {
return Clips[Random.Range(0, Clips.Length)];
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 03f421a8b121f76468bdf7a1961dcbda
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -101,7 +101,6 @@ namespace NeonTea.Quakeball.Networking.Instances {
} else if (packet is SpawnPckt) {
SpawnPckt spawn = (SpawnPckt)packet;
if (spawn.IsInitial) {
Debug.Log("Got spawn!");
if (spawn.PlayerId == LocalPlayer.Id) {
HandlePlayerRespawn(spawn.PlayerId, spawn.Location);
} else {

View File

@ -6,6 +6,7 @@ using NeonTea.Quakeball.Networking.Instances;
using NeonTea.Quakeball.Combat;
using NeonTea.Quakeball.Interface;
using NeonTea.Quakeball.Animation;
using NeonTea.Quakeball.Audio;
namespace NeonTea.Quakeball.Players {
/// <summary>The central glue class for players (both local and remote).</summary>
@ -31,6 +32,7 @@ namespace NeonTea.Quakeball.Players {
public Transform CameraRoot;
public Transform BulletSourcePoint;
public LayerMask BulletHitLayer;
public LayerMask BulletPassLayer;
public float Cooldown;
[Header("Visuals")]
@ -165,7 +167,7 @@ namespace NeonTea.Quakeball.Players {
Vector3 From = CameraRoot.position;
Vector3 Direction = CameraRoot.forward;
RaycastHit[] Hits = Physics.RaycastAll(From, Direction, 1000f, BulletHitLayer);
RaycastHit[] Hits = Physics.RaycastAll(From, Direction, 1000f, BulletHitLayer | BulletPassLayer);
System.Array.Sort(Hits, (a, b) => { return a.distance.CompareTo(b.distance); });
foreach (RaycastHit Hit in Hits) {
ShotDelta = Hit.point - GunPoint;
@ -173,6 +175,13 @@ namespace NeonTea.Quakeball.Players {
if (Player == this) {
continue;
}
if (((1 << Hit.collider.gameObject.layer) & BulletPassLayer) != 0) {
ImpactSound ImpactSound = Hit.collider.GetComponent<ImpactSound>();
if (ImpactSound != null) {
ImpactSound.PlayAt(Hit.point);
}
continue;
}
if (Player != null) {
if (Net.Singleton.Instance is Server) {
((Server)Net.Singleton.Instance).SendHit(NetId, Player.NetId);