falldamage sound
This commit is contained in:
@@ -15,6 +15,8 @@ GameObject:
|
||||
- component: {fileID: -8535381027169538}
|
||||
- component: {fileID: 5971260404453589572}
|
||||
- component: {fileID: 4218697106962905645}
|
||||
- component: {fileID: -2923017547529843297}
|
||||
- component: {fileID: 6923417058730395781}
|
||||
m_Layer: 0
|
||||
m_Name: PlayerDroplet
|
||||
m_TagString: Player
|
||||
@@ -189,6 +191,7 @@ MonoBehaviour:
|
||||
dashingCooldown: 1
|
||||
tr: {fileID: 0}
|
||||
animator: {fileID: 4218697106962905645}
|
||||
fallingAnimationVelocityThreshold: 3
|
||||
--- !u!111 &5971260404453589572
|
||||
Animation:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -229,3 +232,121 @@ Animator:
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorStateOnDisable: 0
|
||||
m_WriteDefaultValuesOnDisable: 0
|
||||
--- !u!82 &-2923017547529843297
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2141180002423843430}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_Resource: {fileID: 8300000, guid: a2bc0335c81b4244397158d9fcb5f586, type: 3}
|
||||
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: 0
|
||||
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!114 &6923417058730395781
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2141180002423843430}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2b3b9fc97a2d39d2d84c4be43a79247a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::DamageHandler
|
||||
threshold: 12
|
||||
multiplier: 0.1
|
||||
maxHealth: 1
|
||||
health: 0
|
||||
minSize: 0.4
|
||||
maxFallingTime: 2
|
||||
fallingAnimTreshold: 0.2
|
||||
speaker: {fileID: -2923017547529843297}
|
||||
fallsound: {fileID: 8300000, guid: a2bc0335c81b4244397158d9fcb5f586, type: 3}
|
||||
|
||||
@@ -4146,6 +4146,8 @@ MonoBehaviour:
|
||||
minSize: 0.4
|
||||
maxFallingTime: 2
|
||||
fallingAnimTreshold: 0.2
|
||||
speaker: {fileID: 0}
|
||||
fallsound: {fileID: 0}
|
||||
--- !u!1001 &687478031
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -19,6 +19,10 @@ public class DamageHandler : MonoBehaviour
|
||||
public float maxFallingTime = 2f;
|
||||
public float fallingAnimTreshold = 0.2f;
|
||||
|
||||
//audio stuff
|
||||
public AudioSource speaker;
|
||||
public AudioClip fallsound;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -70,11 +74,23 @@ public class DamageHandler : MonoBehaviour
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D other)
|
||||
{
|
||||
// Debug.LogWarning("collide");
|
||||
//on collision check fall damage
|
||||
float fallSpeed = lastYVelocity;
|
||||
|
||||
// Check if we hit hard enough
|
||||
if (fallSpeed < -threshold)
|
||||
{
|
||||
Debug.Log("Impact detected! Speed: " + fallSpeed);
|
||||
|
||||
if (speaker != null && fallsound != null)
|
||||
{
|
||||
speaker.PlayOneShot(fallsound);
|
||||
Debug.Log("Sound played successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("AudioSource or AudioClip is missing in the Inspector!");
|
||||
}
|
||||
|
||||
float fallDamage = (-fallSpeed - threshold) * multiplier;
|
||||
UpdateHealth(health - fallDamage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user