Skip to content

Commit

Permalink
Maetal + Splat sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
szejkerek committed Dec 13, 2023
1 parent 1ce3490 commit 8b36982
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 3 deletions.
Binary file added Assets/Audio/MetalHit.wav
Binary file not shown.
23 changes: 23 additions & 0 deletions Assets/Audio/MetalHit.wav.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Audio/SplatSound.wav
Binary file not shown.
23 changes: 23 additions & 0 deletions Assets/Audio/SplatSound.wav.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Assets/GameData/Audio/MetalHitSound.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9dec4304bb045504e83ddec80e5d3b78, type: 3}
m_Name: MetalHitSound
m_EditorClassIdentifier:
<Clip>k__BackingField: {fileID: 8300000, guid: d746956857ff867439d3321e4a222323, type: 3}
volume: 0.532
pitchVariation: 0.5
loop: 0
<Settings3D>k__BackingField:
spatialBlend: 1
minDistance: 3
maxDistance: 250
8 changes: 8 additions & 0 deletions Assets/GameData/Audio/MetalHitSound.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Assets/GameData/Audio/SplatSound.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9dec4304bb045504e83ddec80e5d3b78, type: 3}
m_Name: SplatSound
m_EditorClassIdentifier:
<Clip>k__BackingField: {fileID: 8300000, guid: 717ae6fd1c401fb4c80954f4de3db568, type: 3}
volume: 0.225
pitchVariation: 0.21
loop: 0
<Settings3D>k__BackingField:
spatialBlend: 1
minDistance: 2.5
maxDistance: 100
8 changes: 8 additions & 0 deletions Assets/GameData/Audio/SplatSound.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Assets/_Prefabs/Player/Weapons/Bullet.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ca55cf9f0376e7f46b2b154be4f59da9, type: 3}
m_Name:
m_EditorClassIdentifier:
collectibleSound: {fileID: 11400000, guid: 1bcd8695d048f204881d3c23c1c92c06, type: 2}
layerMask:
serializedVersion: 2
m_Bits: 256
collectibleSound: {fileID: 11400000, guid: 1bcd8695d048f204881d3c23c1c92c06, type: 2}
woodBreakSound: {fileID: 11400000, guid: fc1c8149f0277cc4fb8a65ce68be5043, type: 2}
splatSound: {fileID: 11400000, guid: 17f967c59e442c04a828c052a53847cb, type: 2}
minExplosionForce: 3
maxExplosionForce: 6
explosionForceRadius: 3.6
Expand Down
4 changes: 3 additions & 1 deletion Assets/_Prefabs/Player/Weapons/Katana.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 53a74136bb70a324e8aa68d49b7ec9d8, type: 3}
m_Name:
m_EditorClassIdentifier:
collectibleSound: {fileID: 11400000, guid: 1bcd8695d048f204881d3c23c1c92c06, type: 2}
layerMask:
serializedVersion: 2
m_Bits: 256
collectibleSound: {fileID: 11400000, guid: 1bcd8695d048f204881d3c23c1c92c06, type: 2}
sliceSound: {fileID: 11400000, guid: 08bf85da2d08fd744b29b2e5128c4fe2, type: 2}
metalHitSound: {fileID: 11400000, guid: 2d7719aebab0f1841a9262711b2c92ab, type: 2}
metalHitCooldown: 0.1
sparksEffect: {fileID: 3820671097694520992, guid: 782e934d4cd5a7040a47443cf2ccb214, type: 3}
splashEffect: {fileID: 3433760107342558875, guid: 7ea0ec99985cbf64ca71cdf0b6375c79, type: 3}
startSlicePoint: {fileID: 6065085771502809476}
Expand Down
2 changes: 2 additions & 0 deletions Assets/__Scripts/Player/Weapons/Bullet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class Bullet : Weapon
{
[SerializeField] private Sound woodBreakSound;
[SerializeField] private Sound splatSound;
[Space]
[SerializeField] float minExplosionForce;
[SerializeField] float maxExplosionForce;
Expand Down Expand Up @@ -75,6 +76,7 @@ protected override void SliceableBehavior(Projectile projectile, Vector3 point)
{
projectile.ApplyEffects(false);
projectile.ApplyPoints(negative: true);
AudioManager.Instance.PlayAtPosition(point, splatSound);

}
private void OnCollisionEnter(Collision collision)
Expand Down
10 changes: 10 additions & 0 deletions Assets/__Scripts/Player/Weapons/Katana.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
public class Katana : Weapon
{
[SerializeField] Sound sliceSound;
[SerializeField] Sound metalHitSound;
[SerializeField] float metalHitCooldown;
float lastSound = 0;
[SerializeField] GameObject sparksEffect;
[SerializeField] GameObject splashEffect;
[Space]
Expand All @@ -24,9 +27,16 @@ private void Start()

protected override void ShootableBehavior(Projectile projectile, Vector3 point)
{

Vector3 velocity = endPointVelocity.GetVelocityEstimate();
Vector3 sparksDirection = Vector3.Cross(endSlicePoint.position - startSlicePoint.position, velocity).normalized;
var effect = Instantiate(sparksEffect, point, Quaternion.LookRotation(sparksDirection));
if(Time.time - lastSound >= metalHitCooldown)
{
lastSound = Time.time;
AudioManager.Instance.PlayAtPosition(point, metalHitSound);
}

Destroy(effect, 2f);
projectile.ApplyPoints(negative: true);
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/__Scripts/Player/Weapons/Weapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public abstract class Weapon : MonoBehaviour
{
[SerializeField] Sound collectibleSound;
[SerializeField] LayerMask layerMask;
[SerializeField] Sound collectibleSound;

private void Update()
{
Expand Down

0 comments on commit 8b36982

Please sign in to comment.