push sound

This commit is contained in:
DominikB
2023-06-24 14:22:30 +02:00
parent 63e74b9229
commit d3b407ea48
10 changed files with 490 additions and 1000 deletions

View File

@@ -55,6 +55,14 @@ PrefabInstance:
propertyPath: door
value:
objectReference: {fileID: 0}
- target: {fileID: 1496965085621171596, guid: 189bceaa7696fbf49b6630e96185e2cf, type: 3}
propertyPath: audioSource
value:
objectReference: {fileID: 853924419}
- target: {fileID: 1496965085621171596, guid: 189bceaa7696fbf49b6630e96185e2cf, type: 3}
propertyPath: doorOpenSound
value:
objectReference: {fileID: 8300000, guid: 879f20b26c613da48b68f618ef7607e4, type: 3}
- target: {fileID: 1496965085621171596, guid: 189bceaa7696fbf49b6630e96185e2cf, type: 3}
propertyPath: originalSprite
value:
@@ -67,6 +75,10 @@ PrefabInstance:
propertyPath: activatedSprite
value:
objectReference: {fileID: 21300000, guid: 05df8c93d6e1cc845a1ec24aed20a2ac, type: 3}
- target: {fileID: 1496965085621171596, guid: 189bceaa7696fbf49b6630e96185e2cf, type: 3}
propertyPath: buttonClickSound
value:
objectReference: {fileID: 8300000, guid: 4d73df53fe172084abe41ff9683bb08e, type: 3}
- target: {fileID: 1496965085621171597, guid: 189bceaa7696fbf49b6630e96185e2cf, type: 3}
propertyPath: m_RootOrder
value: 0
@@ -133,6 +145,107 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 189bceaa7696fbf49b6630e96185e2cf, type: 3}
--- !u!1 &6694380534905033864 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1496965085621171599, guid: 189bceaa7696fbf49b6630e96185e2cf, type: 3}
m_PrefabInstance: {fileID: 5197574467279216903}
m_PrefabAsset: {fileID: 0}
--- !u!82 &853924419
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6694380534905033864}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
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: 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!212 &6694380534905033865 stripped
SpriteRenderer:
m_CorrespondingSourceObject: {fileID: 1496965085621171598, guid: 189bceaa7696fbf49b6630e96185e2cf, type: 3}

View File

@@ -22,6 +22,7 @@ GameObject:
- component: {fileID: 7290952889933214358}
- component: {fileID: 1535821441}
- component: {fileID: 1535821442}
- component: {fileID: 3210960092979103452}
m_Layer: 0
m_Name: Frank
m_TagString: Player
@@ -183,6 +184,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a821d8b41cb035c44a9a7c0b05ede9c4, type: 3}
m_Name:
m_EditorClassIdentifier:
audioSource: {fileID: 3210960092979103452}
pushSound: {fileID: 8300000, guid: 79166d94ac54c0641807f1ab87349b61, type: 3}
isPlaying: 0
--- !u!70 &2410396854066836736
CapsuleCollider2D:
m_ObjectHideFlags: 0
@@ -451,3 +455,99 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!82 &3210960092979103452
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2410396854066836738}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
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

View File

@@ -7,6 +7,9 @@ public class IsPushingTester: MonoBehaviour
private Animator animator;
private Rigidbody2D rb;
private bool isColliding;
public AudioSource audioSource; // Reference to the AudioSource component
public AudioClip pushSound; // The sound clip to be played
public bool isPlaying = false; // Boolean to control the sound loop
void Start()
@@ -21,11 +24,20 @@ public class IsPushingTester: MonoBehaviour
if (isColliding && rb.velocity.magnitude > 0.1f)
{
animator.SetBool("IsPushing", true);
if(!isPlaying){
audioSource.clip = pushSound;
audioSource.loop = true;
audioSource.Play();
isPlaying = true;}
}
else
{
animator.SetBool("IsPushing", false);
audioSource.Stop();
isPlaying = false;
}
}

View File

@@ -10,6 +10,7 @@ public Sprite originalSprite;
public Sprite activatedSprite;
public AudioSource audioSource; // Reference to the AudioSource component
public AudioClip buttonClickSound; // The sound clip to be played
public AudioClip doorOpenSound;
private bool isActive = false;
// Start is called before the first frame update
void Start()
@@ -29,6 +30,7 @@ void OnTriggerEnter2D(Collider2D other) {
spriteRenderer.sprite = activatedSprite;
if(!isActive){
audioSource.PlayOneShot(buttonClickSound);
audioSource.PlayOneShot(doorOpenSound);
isActive = true;
}
}